#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-11;
const int mod = 1e7 + 9;
const int oo = (1 << 31) - 1;
template <class T>
inline void readInt(T &n) {
  n = 0;
  T ch = getchar();
  int sign = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') sign = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    n = (n << 3) + (n << 1) + ch - '0', ch = getchar();
  n = n * sign;
}
const int maxn = 100005;
int n, m, q, x, y, a[505][505], b[505];
int main() {
  cin >> n >> m >> q;
  for (int i = ((int)(0)); i < ((int)(n)); i++) b[i] = 0;
  for (int i = ((int)(0)); i < ((int)(n)); i++)
    for (int j = ((int)(0)); j < ((int)(m)); j++) cin >> a[i][j];
  for (int i = ((int)(0)); i < ((int)(n)); i++) {
    int c = a[i][0];
    for (int j = ((int)(1)); j < ((int)(m)); j++) {
      if (a[i][j] == 0) {
        if (a[i][j - 1] == 1) b[i] = max(b[i], c);
        c = 0;
        continue;
      }
      if (a[i][j - 1] == 0)
        c = 1;
      else
        c++;
    }
    b[i] = max(b[i], c);
  }
  for (int i = ((int)(0)); i < ((int)(q)); i++) {
    cin >> x >> y;
    --x;
    --y;
    a[x][y] = 1 - a[x][y];
    int res = 0, c = a[x][0];
    for (int j = ((int)(1)); j < ((int)(m)); j++) {
      if (a[x][j] == 0) {
        if (a[x][j - 1] == 1) res = max(res, c);
        c = 0;
        continue;
      }
      if (a[x][j - 1] == 0)
        c = 1;
      else
        c++;
    }
    res = max(res, c);
    b[x] = res;
    res = 0;
    for (int j = ((int)(0)); j < ((int)(n)); j++)
      if (b[j] > res) res = b[j];
    cout << res << endl;
  }
  return 0;
}
