#include <bits/stdc++.h>
int a[505][505];
int csm[505];
int m, n, q;
int main() {
  scanf("%d %d %d", &m, &n, &q);
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  int sm = 0, mx = 0;
  for (int i = 1; i <= m; i++) {
    sm = 0;
    mx = 0;
    for (int j = 1; j <= n; j++) {
      if (a[i][j] == 1) {
        sm++;
      } else {
        sm = 0;
      }
      if (mx < sm) {
        mx = sm;
      }
    }
    csm[i] = mx;
  }
  int g1, g2;
  int ans = 0;
  for (int i = 0; i < q; i++) {
    scanf("%d %d", &g1, &g2);
    ans = 0;
    a[g1][g2] = 1 - a[g1][g2];
    sm = 0;
    mx = 0;
    for (int j = 1; j <= n; j++) {
      if (a[g1][j] == 1) {
        sm++;
      } else {
        sm = 0;
      }
      if (mx < sm) {
        mx = sm;
      }
      csm[g1] = mx;
    }
    for (int j = 1; j <= m; j++) {
      if (ans < csm[j]) {
        ans = csm[j];
      }
    }
    printf("%d\n", ans);
  }
}
