10919 - Enemy at the gates-EECS   

Description

The kingdom of far worse is in trouble.

The enemies are going to attack kingdom of far worse.

 

The enemies have map of kingdom of far worse. The map shows that there are exactly some cities.

They are planning to isolate some cities of kingdom of far worse and their method is bomb some roads.

 

For example, there is a road between city 2 and city 3.

If the position of a bomb is (2, 3), the road from city 2 to city 3 will be destroyed by the bomb but there is still a road from 3 to 2.

 

The king of kingdom of far worse request you to write a program to show that which city does NOT have road can leave or enter it.

 

Note:

Below is a real map and its representation of 2-D array. Left-up is (1, 1).

 

For example of left part.

(1, 4) is 1, means there is a road from 1 to 4.

(4, 3) is 1, means there is a road from 4 to 3

(1, 2).is 0, means there is NO road from 1 to 2.

Input

One number N, N is the number of cities. 2 <= N <= 50

Following is a 2-D array map with N columns and N rows.

One number B, B is the number of bombs. 1 <= B <= N2

Following is B lines, each line is the position of bomb.

Output

Which city does NOT have road can leave or enter it.

The order of number is increasing. Each number is printed by format "%d\n" 

Sample Input  Download

Sample Output  Download

Tags




Discuss