#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, q, s, x, y, c = 0, _max = 0;
  cin >> n >> m >> q;
  bool arr[505][505];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf(" %d", &s);
      if (s == 1) {
        arr[i][j] = true;
      } else
        arr[i][j] = false;
    }
  }
  for (int i = 0; i < q; i++) {
    scanf(" %d %d", &x, &y);
    arr[x - 1][y - 1] = !arr[x - 1][y - 1];
    for (int l = 0; l < n; l++) {
      c = 0;
      for (int j = 0; j < m; j++) {
        if (arr[l][j]) {
          c++;
        } else {
          c = 0;
        }
        _max = max(_max, c);
      }
    }
    printf(" %d\n", _max);
    _max = 0;
    c = 0;
  }
  return 0;
}
