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.*;
import java.math.*;
import java.io.*;
public class cf547 {
	public static Scanner I=new Scanner(System.in);
	static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	static PrintWriter out = new PrintWriter(System.out);
	public static void A() {
		String str=I.nextLine();
		int len=str.length();
		int k=I.nextInt();
		String re="NO";
		if(len%k==0) {
			int sub=len/k;
			for(int i=0; i<k; i++) {
				if(!isPalindrome(str.substring(0,sub))) {break;}
				str=str.substring(sub);
			}
			if(str.equals("")) re="YES";
		}
		System.out.println(re);
	}
	public static boolean isPalindrome(String str) {
		int j=str.length()-1;
		int i=0;
		while(i<j) {
			if(str.charAt(i)!=str.charAt(j)) return false;
			i++;
			j--;
		}
		return true;
	}
	public static int rowMax(int[]A) {
		int max=A[0];
		for(int q:A) {
			max=Math.max(max,q);
		}
		return max;
	}
	public static int colMax(int[]A) {
		int max=0;
		int n=A.length;
		for(int j=0; j<n; j++) {
			if(A[j]==1) {
				int count=0;
				while(j<n && A[j]==1) {
					count++;
					j++;
				}
				max=Math.max(max,count);
			}
		}
		return max;
	}
	public static void B() {
		int m=I.nextInt();
		int n=I.nextInt();
		int Q=I.nextInt();
		int [][]A=new int[m][n];
		int []locals=new int[m];
		for(int i=0; i<m; i++) {
			for(int j=0; j<n; j++) {
				A[i][j]=I.nextInt();
			}
			locals[i]=colMax(A[i]);
		}
		for(int q=0; q<Q; q++) {
			int X=I.nextInt()-1;
			int Y=I.nextInt()-1;
			if(A[X][Y]==0) A[X][Y]=1;
			else A[X][Y]=0;
			locals[X]=colMax(A[X]);
			int max=rowMax(locals);
			System.out.println(max);
		}
	}

	public static void C() {
		int m=I.nextInt();
		int h1=I.nextInt();
		int a1=I.nextInt();
		int x1=I.nextInt();
		int y1=I.nextInt();
		int h2=I.nextInt();
		int a2=I.nextInt();
		int x2=I.nextInt();
		int y2=I.nextInt();
		int i=0;
		int re=-1;
		for(i=1; i<100000000; i++) {
			h1=(int)(((long)x1*h1+y1)%m);
			h2=(int)(((long)x2*h2+y2)%m);
			//System.out.printf("%d %d i: %d%n",h1,h2,i);
			if(h1==a1 && h2==a2) {re=i; break;}
		}
		System.out.println(re);
	}
	public static void D() {
		int N=I.nextInt();
		int[]A=new int[N];
		int min=I.nextInt();
		int max=min;
		for(int n=1; n<N; n++) {
			A[n]=I.nextInt();
			min=Math.min(min,A[n]);
			max=Math.max(max,A[n]);
		}
		for(int n=1; n<N; n++) {
			int localMin=A[0];
			for(int i=1; i<=n; i++) {
				localMin=Math.min(localMin,A[i]);
			}

		}
	}
	public static void main(String[] args) throws Exception{
		B();

	}
}
