description: 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.
solution: /*
                         _oo0oo_
                        o8888888o
                        88" . "88
                        (| -_- |)
                        0\  =  /0
                      ___/`---'\___
                    .' \\|     |// '.
                   / \\|||  :  |||// \
                  / _||||| -:- |||||- \
                 |   | \\\  -  /// |   |
                 | \_|  ''\---/''  |_/ |
                 \  .-\__  '-'  ___/-. /
               ___'. .'  /--.--\  `. .'___
            ."" '<  `.___\_<|>_/___.' >' "".
           | | :  `- \`.;`\ _ /`;.`/ - ` : | |
           \  \ `_.   \_ __\ /__ _/   .-` /  /
       =====`-.____`.___ \_____/___.-`___.-'=====
                         `=---='
   
  */
  
  import java.util.*;
  import java.math.*;
  import java.io.*;
  import java.lang.Math.*;
  
  // @author : dhruvil_8803
  
  public class KickStart2020 {
  	 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());
  		}
  
  		float nextFloat() {
  			return Float.parseFloat(next());
  		}
  
  		String nextLine() {
  			String str = "";
  			try {
  				str = br.readLine();
  			} catch (IOException e) {
  				e.printStackTrace();
  			}
  			return str;
  		}
  	}
  
  	static long gcd(long a, long b) {
  		if (b == 0)
  			return a;
  		return gcd(b, a % b);
  
  	}
  
  	static long lcm(long a, long b) {
  		return a / gcd(a, b) * b;
  	}
  
  	public static class Pair implements Comparable<Pair> {
  		public long index;
  		public long value;
  
  		public Pair(long index, long value) {
  			this.index = index;
  			this.value = value;
  		}
  
  		@Override
  		public int compareTo(Pair other) {
  			// multiplied to -1 as the author need descending sort order
  			if(other.index < this.index) return 1;
  			if(other.index > this.index) return -1;
  			if(other.value < this.value) return -1;
  			if(other.value > this.value) return 1;
  			else return 0;
  		}
  		@Override
  		public String toString() {
  			return this.index + " " + this.value;
  		}
  	}
  	static boolean isPrime(long d) {
  		if (d == 1)
  			return false;
  		for (int i = 2; i <= (long) Math.sqrt(d); i++) {
  			if (d % i == 0)
  				return false;
  		}
  		return true;
  	}
  	static void decimalTob(int n, int k, Stack<Integer> ss) {
            int x = n % k;
            int y = n / k;
            ss.push(x);
            if(y > 0) {
          	   decimalTob(y, k, ss);
            }
  	}
  	static long powermod(long x, long y, long mod) {
  		long ans = 1;
  		x = x % mod;
  		if (x == 0)
  			return 0;
  		int i = 1;
  		while (y > 0) {
  			if ((y & 1) != 0)
  				ans = (ans * x) % mod;
  			y = y >> 1;
  			x = (x * x) % mod;
  		}
  		return ans;
  	}
  	public static void main(String[] args) throws Exception {
  		FastReader sc = new FastReader();
  		PrintWriter out = new PrintWriter(System.out);
  		int t = 1;
  		outerloop:
          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();
          for(int i = 0; i < k; i++) {
          	int y = sc.nextInt();
          	int x = 0;
          	y--;
          	while(x < n) {
          		if(arr[x][y] == 1) {
          			arr[x][y] = 2;
          			y++;
          		}
          		else if(arr[x][y] == 2) {
          			arr[x][y] = 2;
          			x++;
          		}
          		else {arr[x][y] = 2;
          			y--;
          		}
          	}
          	out.print((y + 1) + " ");
          }
          out.println();
          }
  		out.close();
  	}
  }