Mike and some bears are playing a game just for fun. Mike is the judge. All bears except Mike are standing in an n × m grid, there's exactly one bear in each cell. We denote the bear standing in column number j of row number i by (i, j). Mike's hands are on his ears (since he's the judge) and each bear standing in the grid has hands either on his mouth or his eyes.

<image>

They play for q rounds. In each round, Mike chooses a bear (i, j) and tells him to change his state i. e. if his hands are on his mouth, then he'll put his hands on his eyes or he'll put his hands on his mouth otherwise. After that, Mike wants to know the score of the bears.

Score of the bears is the maximum over all rows of number of consecutive bears with hands on their eyes in that row.

Since bears are lazy, Mike asked you for help. For each round, tell him the score of these bears after changing the state of a bear selected in that round. 

Input

The first line of input contains three integers n, m and q (1 ≤ n, m ≤ 500 and 1 ≤ q ≤ 5000).

The next n lines contain the grid description. There are m integers separated by spaces in each line. Each of these numbers is either 0 (for mouth) or 1 (for eyes).

The next q lines contain the information about the rounds. Each of them contains two integers i and j (1 ≤ i ≤ n and 1 ≤ j ≤ m), the row number and the column number of the bear changing his state.

Output

After each round, print the current score of the bears.

Examples

Input

5 4 5
0 1 1 0
1 0 0 1
0 1 1 0
1 0 0 1
0 0 0 0
1 1
1 4
1 1
4 2
4 3


Output

3
4
3
3
4
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.function.BiConsumer;
import java.io.IOException;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;

public class S {
	
	static private long ans;
	static private long count1;
	static private long count2;
	static private long tmp;
	
	private static int[][] arr;
	private static int n;
	
	private static long[] larr;
	private static int r1,r2,r3;
	private static int c1,c2,c3;
	private static int p1,p2,p3;
	private static long r;
	private static long min;
	private static long max;
	private static int d;
	private static boolean check;
	
	static class Reader {
		
		static BufferedReader reader;
		static StringTokenizer tokenizer;
		
		static void init(InputStream input) {
			reader = new BufferedReader(new InputStreamReader(input));
			tokenizer = new StringTokenizer("");
		}
		
		static String next() throws IOException {
			while(!tokenizer.hasMoreTokens()) {
				tokenizer = new StringTokenizer(reader.readLine());
			}
			return tokenizer.nextToken();
		}
		
		static int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
		
		static long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		
	}

	static int[] merge(int[] a, int[] b) {
		int m = a.length;
		int n = b.length;
		int [] c = new int[n+m];
		
		int j=0, k=0;
		while(j+k<m+n) {
			if(j>=m) {
				c[j+k] = b[k];
				k++;
			}
			else if(k>=n) {
				c[j+k] = a[j];
				j++;
			}
			else {
				if(a[j]<b[k]) {
					c[j+k] = a[j];
					j++;
				}
				else if(a[j]==b[k]) {
					if(a[j]<b[k]) {
						c[j+k] = a[j];
						j++;
					}
					else {
						c[j+k] = b[k];
						k++;
					}
				}
				else {
					c[j+k] = b[k];
					k++;
				}
			}
		}
		return c;
	}
	
	static int[] Msort(int[] unsorted){
		int l = unsorted.length;
		
		if(l<=1) {
			return unsorted;
		}
		
		else {
			int[] Msorted = new int[l];
			int[] m1 = new int[l/2];
			int[] m2 = new int[l-(l/2)];
			
			for(int i=0; i<l; i++) {
				if(i<l/2) {
					m1[i] = unsorted[i];
				}
				else {
					m2[i-(l/2)] = unsorted[i];
				}
			}
			
			Msorted = merge(Msort(m1), Msort(m2));		
			
			return Msorted;
		}
		
	}
	
	static long[] merge(long[] a, long[] b) {
		int m = a.length;
		int n = b.length;
		long [] c = new long[n+m];
		
		int j=0, k=0;
		while(j+k<m+n) {
			if(j>=m) {
				c[j+k] = b[k];
				k++;
			}
			else if(k>=n) {
				c[j+k] = a[j];
				j++;
			}
			else {
				if(a[j]<b[k]) {
					c[j+k] = a[j];
					j++;
				}
				else if(a[j]==b[k]) {
					if(a[j]<b[k]) {
						c[j+k] = a[j];
						j++;
					}
					else {
						c[j+k] = b[k];
						k++;
					}
				}
				else {
					c[j+k] = b[k];
					k++;
				}
			}
		}
		return c;
	}
	
	static long[] Msort(long[] unsorted){
		int l = unsorted.length;
		
		if(l<=1) {
			return unsorted;
		}
		
		else {
			long[] Msorted = new long[l];
			long[] m1 = new long[l/2];
			long[] m2 = new long[l-(l/2)];
			
			for(int i=0; i<l; i++) {
				if(i<l/2) {
					m1[i] = unsorted[i];
				}
				else {
					m2[i-(l/2)] = unsorted[i];
				}
			}
			
			Msorted = merge(Msort(m1), Msort(m2));		
			
			return Msorted;
		}
		
	}

	static int[][] merge_x(int[][] a, int[][] b) {
		int m = a.length;
		int n = b.length;
		int [][] c = new int[n+m][2];
		
		int j=0, k=0;
		while(j+k<m+n) {
			if(j>=m) {
				c[j+k][0] = b[k][0];
				c[j+k][1] = b[k][1];
				k++;
			}
			else if(k>=n) {
				c[j+k][0] = a[j][0];
				c[j+k][1] = a[j][1];
				j++;
			}
			else {
				if(a[j][0]<b[k][0]) {
					c[j+k][0] = a[j][0];
					c[j+k][1] = a[j][1];
					j++;
				}
				else if(a[j][0]==b[k][0]) {
					if(a[j][1]<b[k][1]) {
						c[j+k][0] = a[j][0];
						c[j+k][1] = a[j][1];
						j++;
					}
					else {
						c[j+k][0] = b[k][0];
						c[j+k][1] = b[k][1];
						k++;
					}
				}
				else {
					c[j+k][0] = b[k][0];
					c[j+k][1] = b[k][1];
					k++;
				}
			}
		}
		return c;
	}
	
	static int[][] Msort_x(int[][] unsorted){
		int l = unsorted.length;
		
		if(l<=1) {
			return unsorted;
		}
		
		else {
			int[][] Msorted = new int[l][2];
			int[][] m1 = new int[l/2][2];
			int[][] m2 = new int[l-(l/2)][2];
			
			for(int i=0; i<l; i++) {
				if(i<l/2) {
					m1[i][0] = unsorted[i][0];
					m1[i][1] = unsorted[i][1];
				}
				else {
					m2[i-(l/2)][0] = unsorted[i][0];
					m2[i-(l/2)][1] = unsorted[i][1];
				}
			}
			
			Msorted = merge_x(Msort_x(m1), Msort_x(m2));
			
			return Msorted;
		}
		
	}
	
	static int[][] merge_y(int[][] a, int[][] b) {
		int m = a.length;
		int n = b.length;
		int [][] c = new int[n+m][2];
		
		int j=0, k=0;
		while(j+k<m+n) {
			if(j>=m) {
				c[j+k][0] = b[k][0];
				c[j+k][1] = b[k][1];
				k++;
			}
			else if(k>=n) {
				c[j+k][0] = a[j][0];
				c[j+k][1] = a[j][1];
				j++;
			}
			else {
				if(a[j][1]<b[k][1]) {
					c[j+k][0] = a[j][0];
					c[j+k][1] = a[j][1];
					j++;
				}
				else if(a[j][1]==b[k][1]) {
					if(a[j][0]<b[k][0]) {
						c[j+k][0] = a[j][0];
						c[j+k][1] = a[j][1];
						j++;
					}
					else {
						c[j+k][0] = b[k][0];
						c[j+k][1] = b[k][1];
						k++;
					}
				}
				else {
					c[j+k][0] = b[k][0];
					c[j+k][1] = b[k][1];
					k++;
				}
			}
		}
		return c;
	}
	
	static int[][] Msort_y(int[][] unsorted){
		int l = unsorted.length;
		
		if(l<=1) {
			return unsorted;
		}
		
		else {
			int[][] Msorted = new int[l][2];
			int[][] m1 = new int[l/2][2];
			int[][] m2 = new int[l-(l/2)][2];
			
			for(int i=0; i<l; i++) {
				if(i<l/2) {
					m1[i][0] = unsorted[i][0];
					m1[i][1] = unsorted[i][1];
				}
				else {
					m2[i-(l/2)][0] = unsorted[i][0];
					m2[i-(l/2)][1] = unsorted[i][1];
				}
			}
			
			Msorted = merge_y(Msort_y(m1), Msort_y(m2));
			
			return Msorted;
		}
		
	}
	
	static int[][] merge_3(int[][] a, int[][] b) {
		int m = a.length;
		int n = b.length;
		int [][] c = new int[n+m][3];
		
		int j=0, k=0;
		while(j+k<m+n) {
			if(j>=m) {
				c[j+k][0] = b[k][0];
				c[j+k][1] = b[k][1];
				c[j+k][2] = b[k][2];
				k++;
			}
			else if(k>=n) {
				c[j+k][0] = a[j][0];
				c[j+k][1] = a[j][1];
				c[j+k][2] = a[j][2];
				j++;
			}
			else {
				if(a[j][0]<b[k][0]) {
					c[j+k][0] = a[j][0];
					c[j+k][1] = a[j][1];
					c[j+k][2] = a[j][2];
					j++;
				}
				else if(a[j][0]==b[k][0] && a[j][1]<b[k][1]) {
					c[j+k][0] = a[j][0];
					c[j+k][1] = a[j][1];
					c[j+k][2] = a[j][2];
					j++;
				}
				else {
					c[j+k][0] = b[k][0];
					c[j+k][1] = b[k][1];
					c[j+k][2] = b[k][2];
					k++;
				}
			}
		}
		return c;
	}
	
	
	
	static int[][] Msort_3(int[][] unsorted){
		int l = unsorted.length;
		
		if(l<=1) {
			return unsorted;
		}
		
		else {
			int[][] Msorted = new int[l][3];
			int[][] m1 = new int[l/2][3];
			int[][] m2 = new int[l-(l/2)][3];
			
			for(int i=0; i<l; i++) {
				if(i<l/2) {
					m1[i][0] = unsorted[i][0];
					m1[i][1] = unsorted[i][1];
					m1[i][2] = unsorted[i][2];
				}
				else {
					m2[i-(l/2)][0] = unsorted[i][0];
					m2[i-(l/2)][1] = unsorted[i][1];
					m2[i-(l/2)][2] = unsorted[i][2];
				}
			}
			
			Msorted = merge_3(Msort_3(m1), Msort_3(m2));
			
			return Msorted;
		}
		
	}

	public static void print2dArray(int [][] arr) {
		for(int i=0; i<arr.length; i++) {
			System.out.println(arr[i][0]+" "+arr[i][1]+" ");
		}
	}
	
	public static void printArray(long [] arr) {
		for(int i=0; i<arr.length; i++) {
			System.out.println(arr[i]+" ");
		}
	}
		
	public static void printArray(int [] arr) {
		for(int i=0; i<arr.length; i++) {
			System.out.print(arr[i]+" ");
		}
		System.out.println();
	}
	
    static boolean binarySearch(int arr[], int x, int y) 
    { 
        int l = 0, r = arr.length - 1; 
        while (l <= r) { 
            int m = l + (r - l) / 2; 
  
            // If x greater, ignore left half 
            if (arr[m] < x) 
                l = m + 1; 
  
            // If x is smaller, ignore right half 
            else if(arr[m] > y)
                r = m - 1; 
            
            else {
            	return true;
            }
        } 
  
        // if we reach here, then element was 
        // not present 
        return false; 
    } 
    
    static int gcd(int a, int b) 
    { 
        if (a == 0) 
            return b; 
        return gcd(b % a, a); 
    } 
  
	public static void main(String[] args) throws IOException {
		
		tmp = 0;
		count1 = 0;
		count2 = 0;
		
		ans = 0;
		
		Reader.init(System.in);
		
		OutputStream out = new BufferedOutputStream(System.out);
		
		int r = Reader.nextInt();
		int c = Reader.nextInt();
		
		int t=1;
		t = Reader.nextInt();
		
		boolean[][] bitMtx = new boolean[r][c];
		
		inputBit(bitMtx);
		
		int[] maxR = new int[r];
		
		for(int i=0; i<r; i++) {
			maxR[i] = maxConsec(bitMtx[i]);
		}
		
		main_loop:
		for(int tn=0; tn<t; tn++) {
			
			ans=0;
			
			int i=Reader.nextInt()-1;
			int j=Reader.nextInt()-1;
			
			bitMtx[i][j] = !bitMtx[i][j];
			
			maxR[i] = maxConsec(bitMtx[i]);
			
			int maxC = maxArr(maxR);
			
			
			
			out.write((maxC+"\n").getBytes());
		//	out.write((ans+"\n").getBytes());
		}
		
		out.flush();
		out.close();
		
	}
	
	private static int maxArr(int[] cArr) {
		// TODO Auto-generated method stub
		int cMax=0;
		for(int i=0; i<cArr.length; i++) {
			if(cMax<cArr[i]) {
				cMax = cArr[i];
			}
		}
		return cMax;
	}

	private static int maxConsec(boolean[] bitArr) {
		// TODO Auto-generated method stub
		int tmax = 0, c=0;
		boolean inProgress = false;
		
		for(int i=0; i<bitArr.length; i++) {
			if(bitArr[i]) {
				if(!inProgress) {
					if(c>tmax)
						tmax=c;
					c=0;
					inProgress = true;
				}
				c++;
			}
			else {
				if(inProgress) {
					inProgress=false;
				}
			}
		}
		
		if(c>tmax)
			tmax=c;
		
		return tmax;
	}

	private static void inputBit(boolean[][] bitMtx) throws IOException {
		// TODO Auto-generated method stub
		int a = bitMtx.length;
		int b = bitMtx[0].length;
		
		for(int i=0; i<a; i++) {
			for(int j=0; j<b; j++) {
				bitMtx[i][j] = (Reader.nextInt()==1);
			}
		}		
	}
	
}