Metro
The metro system consists of L
lines, each containing N
stations numbered from 1 to N
. A station can belong to one or more lines. If a station is part of multiple lines, it serves as a junction, allowing transfers between any lines that pass through it. Each line includes at least two stations and has at least one junction. There is a connection between any two stations in the metro, and the travel cost is determined by the lesser of the following two options:
A
kopecks for each station on the route, including both the starting and ending stations.B
kopecks for each line used during the journey.
Your task is to determine the minimum cost in kopecks to travel from station i
to station j
.
Input
The first line provides four natural numbers: N
, L
, A
, and B
. The next L
lines list the station numbers for each metro line in sequence. The final line contains the numbers i
and j
, representing the starting and destination stations, respectively. All numbers are natural, with L ≤ 10
, and all other values do not exceed 100.
Output
Output the minimum number of kopecks required for the trip.