시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB111100.000%

문제

Bob was kidnapped at a street intersection in a city he is unfamiliar with. Kidnappers put him in the car and started driving to their secret hideout. They knew that Bob is unfamiliar with the city so they didn’t blindfold him. Bob decided to remember the way.

City consists of matrix of skyscrapers. There is a street between every two neighboring skyscrapers. Streets are numbered starting from number 1 from top to down and from left to right.

When kidnappers drive through a street, Bob secretly notes down height of the skyscraper to the left of the car and to the right of the car. After the car drives through the intersection, Bob again notes the heights and so on. On every intersection, driver can turn left, go straight, turn right or turn back. When they reached the hideout, Bob sent an SMS with all the heights to the police.

Write the program that will help the police to determine coordinates of the intersection where kidnapper's hideout is.

입력

In the first row there are two integers R and S, 3 ≤ R, S ≤ 100, number of rows and columns of matrix of skyscrapers in the city.

In the next R rows there are S integers per row, heights of the skyscrapers. Every skyscraper is tall at least 1 and at most 10,000.

In the next row there is an integer N, 1 ≤ N ≤ 10,000, length of the path kidnappers drove Bob on.

In the next row there are N numbers, heights of the skyscrapers which Bob saw on the left of the car.

In the next row there are N numbers, heights of the skyscrapers which Bob saw on the right of the car.

출력

In first and only row you should write coordinates (first row, then column) of the intersection where kidnapper's hideout is. If there are multiple solutions, write any one of them.

예제 입력 1

3 3
1 2 3
4 5 6
7 8 9
3
4 2 6
5 5 5


예제 출력 1

2 2


예제 입력 2

4 4
7 3 5 4
2 8 9 7
3 5 2 8
1 3 5 7
5
5 9 8 2 9
2 2 2 8 7


예제 출력 2

1 3


예제 입력 3

4 4
1 2 2 1
2 1 1 2
1 2 1 2
2 1 1 2
5
1 1 1 1 1
2 2 1 2 2


예제 출력 3

1 2