{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"Tram network in Zagreb consists of a number of intersections and rails connecting some of them. In every intersection there is a switch pointing to the one of the rails going out of the intersection. When the tram enters the intersection it can leave only in the direction the switch is pointing. If the driver wants to go some other way, he/she has to manually change the switch.\r\u003cbr\u003e\r\u003cbr\u003eWhen a driver has do drive from intersection A to the intersection B he/she tries to choose the route that will minimize the number of times he/she will have to change the switches manually.\r\u003cbr\u003e\r\u003cbr\u003eWrite a program that will calculate the minimal number of switch changes necessary to travel from intersection A to intersection B.\r\u003cbr\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line of the input contains integers N, A and B, separated by a single blank character, 2 \u0026lt;\u003d N \u0026lt;\u003d 100, 1 \u0026lt;\u003d A, B \u0026lt;\u003d N, N is the number of intersections in the network, and intersections are numbered from 1 to N.\r\u003cbr\u003e\r\u003cbr\u003eEach of the following N lines contain a sequence of integers separated by a single blank character. First number in the i-th line, Ki (0 \u0026lt;\u003d Ki \u0026lt;\u003d N-1), represents the number of rails going out of the i-th intersection. Next Ki numbers represents the intersections directly connected to the i-th intersection.Switch in the i-th intersection is initially pointing in the direction of the first intersection listed.\r\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"The first and only line of the output should contain the target minimal number. If there is no route from A to B the line should contain the integer \"-1\". "}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e3 2 1\r\n2 2 3\r\n2 3 1\r\n2 1 2\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e0\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}