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.

/*
    Author : Kartikey Rana
    from MSIT New Delhi
 */
import java.util.*;
import java.util.Arrays;
import java.util.Collections;
import javax.sql.rowset.serial.SerialArray;
import javax.swing.text.html.HTMLDocument.HTMLReader.PreAction;
import java.io.*;
import java.math.*;
import java.sql.Array;;

public class Main {
	static class FR {

		BufferedReader br;
		StringTokenizer st;

		public FR() {
			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;
		}

		// NEXT INT ARRAY

		int[] NIA(int n) {
			int arr[] = new int[n];
			for (int i = 0; i < n; i++)
				arr[i] = nextInt();
			return arr;
		}

		// NEXT DOUBLE ARRAY

		double[] NDA(int n) {
			double arr[] = new double[n];
			for (int i = 0; i < n; i++)
				arr[i] = nextDouble();
			return arr;
		}

		// NEXT LONG ARRAY

		long[] NLA(int n) {
			long[] arr = new long[n];
			for (int i = 0; i < n; i++)
				arr[i] = nextLong();
			return arr;
		}

		// NEXT STRING ARRAY

		String[] NSA(int n) {
			String[] arr = new String[n];
			for (int i = 0; i < n; i++)
				arr[i] = next();
			return arr;
		}

		// NEXT CHARACTER ARRAY

		char[] NCA(int n) {
			char[] arr = new char[n];
			String s = sc.nextLine();

			for (int i = 0; i < n; i++)
				arr[i] = s.charAt(i);
			return arr;
		}

	}

//*************************  FR CLASS ENDS **********************************

	static long mod = (long) (1e9 + 7);

	public static int[] sieve(int n) {

		int[] primes = new int[n + 1];
		for (int i = 0; i <= n; i++) {
			primes[i] = i;
		}

		for (int i = 2; i < n; i++) {
			if (primes[i] < 0)
				continue;
			if ((long) i * (long) i > n)
				break;
			for (int j = i * i; j < n; j++) {
				if (primes[j] > 0 && primes[j] % primes[i] == 0)
					primes[j] = -primes[j];
			}
		}
		return primes;
	}

	static int lcm(int a, int b) {
		return (int) ((a / gcd(a, b)) * b);
	}

	static long gcd(long a, long b) {
		if (b == 0)
			return a;

		return gcd(b, a % b);
	}

	static long[][] ncr(int n, int k) {
		long C[][] = new long[n + 1][k + 1];
		int i, j;

		// Calculate value of Binomial
		// Coefficient in bottom up manner
		for (i = 0; i <= n; i++) {
			for (j = 0; j <= Math.min(i, k); j++) {
				// Base Cases
				if (j == 0 || j == i)
					C[i][j] = 1;

				// Calculate value using
				// previously stored values
				else
					C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
			}
		}

		return C;
	}

	static long modInverse(long a, long m) {
		long g = gcd(a, m);

		return power(a, m - 2, m);

	}

	static long power(long x, long y, long m) {
		if (y == 0)
			return 1;
		long p = power(x, y / 2, m) % m;
		p = (int) ((p * (long) p) % m);
		if (y % 2 == 0)
			return p;
		else
			return (int) ((x * (long) p) % m);
	}

	static int XOR(int n) {
		if (n % 4 == 0)
			return n;

		if (n % 4 == 1)
			return 1;

		if (n % 4 == 2)
			return n + 1;

		return 0;
	}

	/* ***************************************************************************************************************************************************/


	static class Pair implements Comparable<Pair> {

		int x;
		int y;

		public Pair(int x, int y) {
			super();
			this.x = x;
			this.y = y;
		}

		@Override
		public int compareTo(Pair o) {
			return this.x - o.x;
		}

	}
	
	static int[] fact;
	static void factorial(int n) {
		fact = new int[n+1];
		generateFactArray(n+1);
	}
	
	static int generateFactArray(int n) {
		if(n < 2) {
			fact[n] = 1;
			return fact[n];
		}
		
		fact[n] = generateFactArray(n-1);
		return fact[n];
			
	}
	
	static FR sc = new FR();
	static StringBuilder sb = new StringBuilder();
	
	public static void main(String args[]) throws IOException {
		
//		int tc = sc.nextInt();
		int tc = 1;
		while (tc-- > 0) {
			TEST_CASE();
		}
		sb.setLength(sb.length() - 1);
		System.out.println(sb);
	}

	static void TEST_CASE() throws IOException {
		// BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int n =sc.nextInt(), m = sc.nextInt(), 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();
			}
		}
		int[] balls  = sc.NIA(k);
		for(int b : balls) {
			int i = 0, j = b-1;
			while(i < n) {
//				System.out.println(i + " " + j);
				if(arr[i][j] == 1) {
					arr[i][j] = 2;
					j++;
				} else if(arr[i][j] == 2) {
					i++;
				} else {
					arr[i][j] = 2;
					j--;
				}
			}
//			System.out.println("ans " + (int)(j+1));
			sb.append((int)j+1 + " ");		
		}
		
	}
	
	
}




//int n = sc.nextInt();
//
//int[] arr = sc.NIA(n);
//
//Arrays.sort(arr);
//
//float c = 0;
//int sum = 0;
//for(int i  :arr) {
//	c += i;
//	sum += i;
//}
//c = c/arr.length;
//
//if(c%1 != 0) {
//	sb.append("0\n");
//	return;
//}
//
//int x = (int)c * (arr.length - 2);
//x = sum - x;
//int ans = 0;
//
//for(int i = 0; i < arr.length-1; i++) {
//	if(arr[i]/2 > x)
//		break;
//	for(int j = i+1; j < arr.length; j++) {
//		if(arr[i] + arr[j] > x)
//			break;
//		else if(arr[i] + arr[j] == x)
//			ans++;
//	}
//}
//sb.append(ans+"\n");
//
//
//
//
//
//
//
//
//
//
//
//


//
