410655: GYM104069 G Grand Meeting

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

G. Grand Meetingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Cássio and Morete - coach and co-coaches of MaratonUSP, respectively - need to carry out a top-secret meeting where they will decide the future of the extension group, and also the plan of domination of the other extension groups. Because both live near line 4 yellow - an infamous subway line of the city of Sao Paulo - they decided to use it as a means of transportation to the place of the meeting.

Given the extreme importance of the meeting, Cássio and Morete decided that they won't settle on the final location of the meeting through the internet, afraid of spying on other extension groups, such as SegurIME (university cybersecurity group). They embarked at the nearest stations of their respective homes and will meet as soon as possible, to settle on the final location of the meeting.

Because the Laboratorio De Codigo (code lab, in Portuguese) could have sabotaged the subway app, they asked your help to find the minimum amount of time it takes for them to meet. Keep in mind that it takes 1 minute to go from one station to the next and both coaches embark at their stations in the same instant.

Input

The first line contains an integer $$$n$$$ $$$(1 \leq n \leq 100)$$$ - the number of stations of line yellow.

The following $$$n$$$ lines with one string $$$s_i$$$ $$$(1 \leq |s_i| \leq 100)$$$ of lowercase letters each - the name of de $$$i$$$-th station of line yellow, following the orientation west-east. It is guaranteed that no pair of stations have the same name.

Then, there is a line with two strings $$$c$$$ and $$$m$$$ - the stations where Cássio and Morete embark, respectively. It is guaranteed that $$$c$$$ and $$$m$$$ are the names of line yellow stations.

Output

Print a single integer, the minimum time needed for them to meet at some station.

ExampleInput
7
butanta
pinheiros
faria
fradique
oscar
paulista
luz
pinheiros oscar
Output
2

加入题单

上一题 下一题 算法标签: