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.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class a {
	public static class node {
		int node;
		int val;
		int idx;

		node(int index, int val, int r) {
			node = index;
			this.val = val;
			idx = r;
		}

	}

	public static class point implements Comparable<point> {
		int x;
		long val;

		point(int x, long val) {
			this.x = x;
			this.val = val;
		}

		public int compareTo(point o) {
			if (o.val < val)
				return 1;
			else if (o.val > val)
				return -1;

			return 0;
		}

	}

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

	public static ArrayList<Integer> prime;

	public static void sieve(int n) {
		boolean vis[] = new boolean[n + 5];
		vis[1] = true;
		vis[0] = true;
		for (int i = 2; i <= n; i++) {
			if (!vis[i]) {
				prime.add(i);
				for (long j = (long) i * (long) i; j <= n; j += i) {
					vis[(int) j] = true;
				}
			}
		}
	}

	public static int tree[][];
	public static boolean end[][];
	public static int counter;

	public static void trie(String a) {
		int st = 0;

		for (int i = 0; i < a.length(); i++) {
			if (tree[a.charAt(i) - 'a'][st] == 0) {
				tree[a.charAt(i) - 'a'][st] = counter++;
			}

			st = tree[a.charAt(i) - 'a'][st];
		}
		end[a.charAt(a.length() - 1) - 'a'][st] = true;

	}

	public static int seg[][];
	public static int a[][];
	public static int m;

	public static void build(int s, int e, int p) {
		if (s == e) {
			for (int i = 0; i < m; i++) {
				// System.out.println(p+" "+s);
				seg[i][p] = a[i][s];
			}
			return;
		}
		int mid = (s + e) / 2;
		build(s, mid, p * 2);
		build(mid + 1, e, p * 2 + 1);
		for (int i = 0; i < m; i++) {
			seg[i][p] = Math.max(seg[i][p * 2], seg[i][p * 2 + 1]);
		}
	}

	public static int get(int s, int e, int p, int from, int to, int seg[]) {
		if (s >= from && e <= to)
			return seg[p];
		if (s > to || e < from)
			return 0;
		int mid = (s + e) / 2;
		int one = get(s, mid, p * 2, from, to, seg);
		int two = get(mid + 1, e, p * 2 + 1, from, to, seg);
		return Math.max(one, two);
	}

	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		// BufferedReader in = new BufferedReader(new FileReader(
		// "B-small-attempt0.in"));

		StringBuilder q = new StringBuilder();
		PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
		// PrintWriter out = new PrintWriter(new FileWriter("out.txt"));

		String y[] = in.readLine().split(" ");
		int n = Integer.parseInt(y[0]);
		int m = Integer.parseInt(y[1]);
		int qu = Integer.parseInt(y[2]);

		int a[][] = new int[n][m];
		int ma[] = new int[n];
		for (int i = 0; i < n; i++) {
			y = in.readLine().split(" ");
			for (int j = 0; j < m; j++) {
				a[i][j] = Integer.parseInt(y[j]);
				// System.out.print(a[i][j]+" ");
			}

		}
		int max = 0;

		for (int i = 0; i < n; i++) {
			ma[i] = Math.max(ma[i], a[i][0]);
			for (int j = 1; j < m; j++) {
				if (a[i][j] == 0)
					continue;
				a[i][j] = a[i][j] + a[i][j - 1];
				max = Math.max(max, a[i][j]);
				ma[i] = Math.max(ma[i], a[i][j]);

			}
		}
		for (int i = 0; i < qu; i++) {
			y = in.readLine().split(" ");
			int one = Integer.parseInt(y[0]) - 1;
			int two = Integer.parseInt(y[1]) - 1;
			if (a[one][two] == 0) {
				if (two - 1 >= 0)
					a[one][two] = a[one][two - 1] + 1;
				else
					a[one][two] = 1;

				for (int j = two + 1; j < m; j++) {
					if (a[one][j] == 0)
						break;
					a[one][j] = a[one][j - 1] + 1;
				}
			} else {
				a[one][two] = 0;
				int k = 1;
				for (int j = two + 1; j < m; j++) {
					if (a[one][j] == 0)
						break;
					a[one][j] = k++;
				}
			}

			ma[one] = 0;
			int finMAx = 0;
			for (int j = 0; j < m; j++) {
				ma[one] = Math.max(ma[one], a[one][j]);

			}
			for (int j = 0; j < n; j++) {
				finMAx = Math.max(finMAx, ma[j]);
			}
			// System.out.println(finMAx);
			q.append(finMAx+"\n");
		}
		System.out.println(q);

		out.close();
	}
}