题目描述
NITMAS Fest is live. The members of the community are very busy. People from different colleges have come to compete. But, Naveen is very possessive about his girlfriend, Archana. He always remains close to his girlfriend. Couples (boys in a line and girls in another) have to stand in different rows in a line for a game. There are some mad people in college who think they alone form a couple. It is known that Naveen and Archana are closest of all couples. Find the distance between them.
Input
Each test case consists of 2 lines. The first line represents the girls's line. The second line represents the boys's line. The first number N of each line represents the number of girls or boys in that line. The input numbers may not be in sorted order though. N ≤ 1000. The position of girls or boys is ≤ 1,000,000.
Output
Distance between Naveen and Archana.
Example
Input:
4 2 4 6 8
5 1 3 5 7 9
Output:
1
输入格式
见题面
输出格式
见题面