Metro#2795

Metro

1 second
64 megabytes
Easy

The metro system consists of lines, with stations numbered from to . Each station may belong to one or more lines. If a station is shared by multiple lines, it is a junction and allows transfers between those lines. Each line consists of at least two stations and includes at least one junction. The metro system is connected, meaning there is a route between every pair of stations. The fare for a trip is the lesser of the following two options:

  1. kopecks for each station used along the route, including both the starting and ending stations.

  2. kopecks for each line used along the route.

Determine the minimum fare in kopecks required to travel from station to station .

Input

The first line contains four natural numbers: , , , and .

The next lines each contain the sequence of station numbers belonging to each metro line.

The last line contains the numbers and , representing the starting and destination stations.

All numbers are natural numbers, L \leq 10, all other values do not exceed .

Output

Output the minimum number of kopecks required for the trip.

Examples

Example 1

Loading
Loading