#include <bits/stdc++.h>
using namespace std;
int n, m, q, sm, mx, x, y, ans;
char a[509][509];
int rr[509];
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf(" %c", &a[i][j]);
  for (int i = 1; i <= n; i++) {
    sm = 0, mx = 0;
    for (int j = 1; j <= m; j++) {
      if (a[i][j] == '1')
        sm++;
      else
        mx = max(mx, sm), sm = 0;
    }
    mx = max(mx, sm);
    rr[i] = mx;
  }
  for (int i = 1; i <= q; i++) {
    scanf("%d%d", &x, &y), sm = 0, ans = 0, mx = 0;
    a[x][y] = char(('1' - a[x][y]) + '0');
    for (int j = 1; j <= m; j++) {
      if (a[x][j] == '1')
        sm++;
      else
        mx = max(mx, sm), sm = 0;
    }
    mx = max(mx, sm);
    rr[x] = mx;
    for (int j = 1; j <= n; j++) ans = max(ans, rr[j]);
    printf("%d\n", ans);
  }
  return 0;
}
