A child has drawn N (N<=100) numbered circles of different colors. He has connected some of the circles by colored oriented line segments. Every pair of circles may have any number of segments, with any colors, connecting them. Each color (either circle color or segment color) is assigned its own unique positive integer number not greater than 100.
Starting the game the child first of all chooses three different integers L, K and Q within the range between 1 and N. Then he places one pawn into the circle number L and another one into the circle number K, whereupon he begins to move them using the following rules:
- a pawn can be moved along the line segment, if this segment has the same color with the circle where another pawn is placed,
- the pawn can be moved only in the direction of the segment (all segments are oriented),
- two pawns can never be placed in the same circle at the same time,
- the move order is free (i.e. it is not necessary to move pawns alternately),
- the game ends, when one of the pawns (any of the two) reaches the last circle number Q.
You are to write a program to find out the shortest (i.e. containing a minimal number of moves) solution for this game, if it exists.