A city subway line has become huge and it is hard to take the shortest path through them. You have to find the shortest path in subway lines. In the second , you are in the station and you want to go to the station .
The city has stations. The subway has lines. Each subway line goes to some stations.
The subway goes to stations (in order) and this train takes seconds to travel from to (for and ).
Trains are ready for the passengers to get in, but the last train goes in the second (and you are allowed to board it in between the path).
Input
The first line contains (in order).
Next lines describe subway lines.
The first line contains and next line contains and the next line contains .
The last line containts .
It is guaranteed and no subway line intersects itself.
Output
Print the shortest path in subway lines from the station to .
If there is no way from to , print -1.
Constraints
In second get on first subway line and in next second we arrive to station and we can get on second line and arrive to in second