The tram network in Zagreb consists of a number of intersections and rails connecting some of them. At each intersection, there is a switch pointing to one of the rails leaving that intersection. When a tram enters an intersection, it can leave only in the direction the switch is currently pointing. If the driver wants to go in another direction, they must manually change the switch.
When a driver needs to travel from intersection to intersection , they try to choose a route that minimizes the number of times the switches must be changed manually.
Write a program that calculates the minimal number of switch changes required to travel from intersection to intersection .
The first line contains three integers , , and (2 \leq N \leq 100, 1 \leq A, B \leq N), separated by single spaces, where is the number of intersections in the network. Intersections are numbered from to .
Each of the following lines contains a sequence of integers separated by single spaces. The first number in the -th line, K_i (0 \leq K_i \leq N-1), is the number of rails outgoing from the -th intersection. The next K_i numbers are the intersections directly connected to the -th intersection. The switch at the -th intersection is initially pointing in the direction of the first listed intersection on that line.
Print a single integer: the minimal number of switch changes needed. If there is no route from to , print .
Example 1