Problem: 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

Solution (in JAVA):

Solution:
import java.util.*;
import java.io.*;

public class B548
{
	
public static void main(String[] args)
{
		
		InputReader in=new InputReader(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		
		int n = in.nextInt();
		int m = in.nextInt();
		int q = in.nextInt();
		int[][] a = new int[n+1][m+1];
		int[][] sum = new int[n+1][m+1];
		pair[] pair = new pair[n+1];
		int index=0;
		
		for(int i=0;i<n+1;i++)
			pair[i] = new pair(0,0);
		
		for(int i=1;i<n+1;i++)
		{
			pair[i].y = i;
			for(int j=1;j<m+1;j++)
			{
				a[i][j] = in.nextInt();
				
				if(a[i][j]==1)
					sum[i][j] = sum[i][j-1] + a[i][j];
				
				pair[i].x = Math.max(pair[i].x, sum[i][j]);
			}
		}
		
		for(int i=0;i<q;i++)
		{
			int p = in.nextInt();
			int r = in.nextInt();
			
			if(a[p][r]==1)
			{
				a[p][r]=0;
				sum[p][r]=0;
				
				for(int j=1;j<n+1;j++)
				{
					if(p==pair[j].y)
						index=j;
				}
				
				pair[index].x=0;
				
				for(int j=1;j<m+1;j++)
				{
					if(a[p][j]==1)
					{
						sum[p][j] = sum[p][j-1] + a[p][j];
						//System.out.println(sum[p][j-1]+" "+a[p][j]+" "+pair[index].x+" "+index);
						pair[index].x = Math.max(pair[index].x, sum[p][j]);
					}
				}
				Arrays.sort(pair);
				System.out.println(pair[n].x);
			}
			else
			{
				a[p][r]=1;
				
				for(int j=1;j<n+1;j++)
				{
					if(p==pair[j].y)
						index=j;
				}
				
				pair[index].x=0;
				
				for(int j=1;j<m+1;j++)
				{
					if(a[p][j]==1)
					{
						sum[p][j] = sum[p][j-1] + a[p][j];
						pair[index].x = Math.max(pair[index].x, sum[p][j]);
					}
				}
				Arrays.sort(pair);
				System.out.println(pair[n].x);
			}
		}
		
		/*for(int i=1;i<n+1;i++)
		{
			for(int j=1;j<m+1;j++)
				System.out.print(a[i][j]+" ");
			System.out.println();
		}
		System.out.println();
		for(int i=1;i<n+1;i++)
		{
			for(int j=1;j<m+1;j++)
				System.out.print(sum[i][j]+" ");
			System.out.println();
		}*/
		
			
	       pw.flush();
		pw.close();
	}

static class pair implements Comparable<pair>
{
	Integer x, y;
	pair(int x,int y)
	{
		this.x=x;
		this.y=y;
	}
	
	public int compareTo(pair o) {
		int result = x.compareTo(o.x);
		if(result==0)
			result = y.compareTo(o.y);
		
		return result;
	}  
	
	public String toString()
	{
		return x+" "+y;
	}
	
	public boolean equals(Object o)
	{
		if (o instanceof pair)
	    {
			pair p = (pair)o;
			return p.x == x && p.y == y ;
		}
		return false;
	}
	
	public int hashCode()
	{
		return new Long(x).hashCode()*31 + new Long(y).hashCode();
	}
}

	
	static class InputReader {
		 
		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;
		private SpaceCharFilter filter;
 
		public InputReader(InputStream stream) {
			this.stream = stream;
		}
 
		public int snext() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}
 
		public int nextInt() {
			int c = snext();
			while (isSpaceChar(c)) {
				c = snext();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}
 
		public long nextLong() {
			int c = snext();
			while (isSpaceChar(c)) {
				c = snext();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}
 
		public int[] nextIntArray(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextInt();
			}
			return a;
		}
		public long[] nextLongArray(int n) {
			long a[] = new long[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextLong();
			}
			return a;
		}
 
		public String readString() {
			int c = snext();
			while (isSpaceChar(c)) {
				c = snext();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = snext();
			} while (!isSpaceChar(c));
			return res.toString();
		}
 
		public String nextLine() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = snext();
			} while (!isEndOfLine(c));
			return res.toString();
		}
 
		public boolean isSpaceChar(int c) {
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}
 
		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}
 
		public interface SpaceCharFilter {
			public boolean isSpaceChar(int ch);
		}
	}


}