Mr. Chanek has a new game called Dropping Balls. Initially, Mr. Chanek has a grid a of size n × m

Each cell (x,y) contains an integer a_{x,y} denoting the direction of how the ball will move.

  * a_{x,y}=1 — the ball will move to the right (the next cell is (x, y + 1)); 
  * a_{x,y}=2 — the ball will move to the bottom (the next cell is (x + 1, y)); 
  * a_{x,y}=3 — the ball will move to the left (the next cell is (x, y - 1)). 



Every time a ball leaves a cell (x,y), the integer a_{x,y} will change to 2. Mr. Chanek will drop k balls sequentially, each starting from the first row, and on the c_1, c_2, ..., c_k-th (1 ≤ c_i ≤ m) columns.

Determine in which column each ball will end up in (position of the ball after leaving the grid).

Input

The first line contains three integers n, m, and k (1 ≤ n, m ≤ 1000, 1 ≤ k ≤ 10^5) — the size of the grid and the number of balls dropped by Mr. Chanek.

The i-th of the next n lines contains m integers a_{i,1},a_{i,2},…,a_{i,m} (1 ≤ a_{i,j} ≤ 3). It will satisfy a_{i, 1} ≠ 3 and a_{i, m} ≠ 1.

The next line contains k integers c_1, c_2, …, c_k (1 ≤ c_i ≤ m) — the balls' column positions dropped by Mr. Chanek sequentially.

Output

Output k integers — the i-th integer denoting the column where the i-th ball will end.

Examples

Input


5 5 3
1 2 3 3 3
2 2 2 2 2
2 2 2 2 2
2 2 2 2 2
2 2 2 2 2
1 2 1


Output


2 2 1 


Input


1 2 2
1 3
1 2


Output


1 2 

Note

In the first example, the first ball will drop as follows. Note that the cell (1, 1) will change direction to the bottom direction.

<image>

The second and third balls will drop as follows. 

<image>

All balls will be dropped from the first row and on the c_1, c_2, ..., c_k-th columns respectively. A ball will stop dropping once it leaves the grid.


import java.util.*;
import java.lang.*;
import java.io.*;


/* Name of the class has to be "Main" only if the class is public. */
public class Pupil
{
   
	
    static FastReader sc = new FastReader();

	public static void main (String[] args) throws java.lang.Exception
	{
	           	
	// your code goes here
             int t=1;
             while(t>0){
            	 int n=sc.nextInt();
            	 int m=sc.nextInt();
            	 int k=sc.nextInt();
            	 int arr[][]=new int[n][m];
            	 for(int i=0;i<n;i++)
            	 {
            		 for(int j=0;j<m;j++)
            		 {
            			 arr[i][j]=sc.nextInt();
            		 }
            	 }
            	 while(k>0)
            	 {
            		int y=sc.nextInt()-1;
            		int x=0;
            	
            		while(x<(n-1) || arr[x][y]==1 || arr[x][y]==3)
            		{
            		
            			 
            				if(arr[x][y]==2)
            				{
            					arr[x][y]=2;
            					x++;
            				}
            				else if(arr[x][y]==1)
            				{
            					arr[x][y]=2;
            					y++;
            				}
            				else {
            					arr[x][y]=2;
            					y--;
            				}
            			}
            		System.out.print((y+1)+" ");
           		 
           		 k--;
            			
            		}
            	
            	 
            	











              t--;
                }

   

 
 
         
	}		
	
	
	
	
	//	FAST I/O
	static class FastReader {
        BufferedReader br;
        StringTokenizer st;
        
        public FastReader()
        {
            br = new BufferedReader(
                new InputStreamReader(System.in));
        }
 
        String next()
        {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt() { return Integer.parseInt(next()); }
 
        long nextLong() { return Long.parseLong(next()); }
 
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
 
        String nextLine()
        {
            String str = "";
            try {
                str = br.readLine();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
	}

public static boolean two(int n)//power of two
{
if((n&(n-1))==0)
{
return true;
}
else{
return false;
}
	
}	





public static boolean isPrime(long n){
		    
		    for (int i = 2; i * i <= n; ++i) {
            if (n % i == 0) {
                return false;
            }
        }
 
        return true;
		}


public static int digit(int n)
{
    int n1=(int)Math.floor((int)Math.log10(n)) + 1;
    return n1;
}

 }
 
 //CAAL THE BELOW FUNCTION IF PARING PRIORITY IS NEEDED //
 
//  PriorityQueue<pair> pq = new PriorityQueue<>(); **********declare the syntax in the main function******
// pq.add(1,2)///////
 
// class pair implements Comparable<pair> {
// 	int value, index;
 
// 	pair(int v, int i) { index = i; value = v; }
 
// 	@Override
// 	public int compareTo(pair o) { return o.value - value; }
// }
 

// User defined Pair class
// class Pair {
//     int x;
//     int y;
  
//     // Constructor
// public Pair(int x, int y)
//     {
//         this.x = x;
//         this.y = y;
//     }
// }


        //     Arrays.sort(arr, new Comparator<Pair>() {
        //     @Override public int compare(Pair p1, Pair p2)
        //     {
        //         return p1.x - p2.x;
        //     }
        // });
        



 
 
 
 
// 		ArrayList<ArrayList<Integer>> connections = new ArrayList<ArrayList<Integer>>();
// 		for(int i = 0; i<n;i++)
// 			connections.add(new ArrayList<Integer>());