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.*;
import java.util.*;

public class B {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        FastPrinter out = new FastPrinter(outputStream);
        TaskS solver = new TaskS();
        solver.solve(1, in, out);
        out.close();
    }
/*В первой строке находится три целых числа, n, m и q (1 ≤ n, m ≤ 500 и 1 ≤ q ≤ 5000).

В следующих n строках задано описание поля. Каждая строка состоит из m целых чисел, разделенных пробелами. Каждое из этих чисел равно либо 0 (закрывается рот), либо 1 (закрываются глаза).

В следующих q строках записана информация о раундах. В каждой из них записано два целых числа, i и j (1 ≤ i ≤ n and 1 ≤ j ≤ m), номер строки и столбца медведя, меняющего состояние.*/

    private static class TaskS {

        public void solve(int testNumber, FastScanner in, FastPrinter out) {
            int N = in.nextInt();
            int M = in.nextInt();
            int Q = in.nextInt();
            BitSet [] bs = new BitSet[N];
            for (int i = 0; i < N; i++ ){
                bs[i] = new BitSet(M);
                for (int j = 0; j < M; j++) {
                    int next = in.nextInt();
                    if (next == 0) {
                        bs[i].set(j, false);
                    } else {
                        bs[i].set(j, true);
                    }
                }
            }

            int[] cache = new int[N];
            int max = 0;
            int maxI = 0;

            for (int i = 0; i < N; i++) {
                cache[i] = calcSch(bs[i]);
                if (cache[i] > max) {
                    max = cache[i];
                    maxI = i;
                }
            }

            List<Integer> result = new ArrayList<>();
            for (int i = 0; i < Q; i++) {
                int x = in.nextInt() - 1;
                int y = in.nextInt() - 1;
                bs[x].flip(y);
                cache[x] = calcSch(bs[x]);
                max = 0;
                for (int k = 0; k < N; k++) {
                    if (max < cache[k]) {
                        max = cache[k];
                    }
                }
                result.add(max);

            }

            for (Integer i : result) {
                out.println(i);
            }
        }

        private int calcSch(BitSet b) {
            int size = 0;
            int maxSize = 0;
            for (int i = 0; i < b.length(); i++) {
                if (b.get(i)) {
                    size++;
                } else  {
                    if (maxSize < size) {
                        maxSize = size;
                    }
                    size = 0;
                }
            }
            if (maxSize < size) {
                maxSize = size;
            }
            return maxSize;
        }

        private boolean isPossible(int d1, int h1, int d2, int h2 ) {
            if (d2-d1 < Math.abs(h2-h1)) {
                return false;
            }
            return true;
        }

        private int getMax(int d1, int h1, int d2, int h2 ) {
            int dSize = d2-d1;
            if (h1 > h2 ) {
                int prom = h1;
                h1 = h2;
                h2 = prom;
            }
            dSize -= h2 - h1;
            return dSize/2 + h2;
        }


/*
        private static void printResult (FastPrinter out, int[] s) {
            out.println(s.length);
            for(int i = 0; i < s.length; i++) {
                out.print(s[i] + " ");
            }
        }
*/
    }

    private static class FastScanner extends BufferedReader {

        public FastScanner(InputStream is) {
            super(new InputStreamReader(is));
        }

        public int read() {
            try {
                return super.read();
            } catch (IOException e) {
                throw new InputMismatchException();
            }
        }

        static boolean isWhiteSpace(int c) {
            return c >= 0 && c <= 32;
        }

        public int nextInt() {
            int c = read();
            while (isWhiteSpace(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int ret = 0;
            while (c >= 0 && !isWhiteSpace(c)) {
                if (c < '0' || c > '9') {
                    throw new NumberFormatException("digit expected " + (char) c
                            + " found");
                }
                ret = ret * 10 + c - '0';
                c = read();
            }
            return ret * sgn;
        }

        public long nextLong() {
            int c = read();
            while (isWhiteSpace(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long ret = 0;
            while (c >= 0 && !isWhiteSpace(c)) {
                if (c < '0' || c > '9') {
                    throw new NumberFormatException("digit expected " + (char) c
                            + " found");
                }
                ret = ret * 10 + c - '0';
                c = read();
            }
            return ret * sgn;
        }

        public String readLine() {
            try {
                return super.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        public int[] readIntArray(int n) {
            int[] ret = new int[n];
            for (int i = 0; i < n; i++) {
                ret[i] = nextInt();
            }
            return ret;
        }
    }

    private static class FastPrinter extends PrintWriter {
        public FastPrinter(OutputStream out) {
            super(out);
        }
    }
}