#include <bits/stdc++.h>
using namespace std;
int a[1000][1000];
struct Tree {
  int value, mx;
  int l, r;
} t[4000000];
void build(int v, int l, int r) {
  t[v].l = l;
  t[v].r = r;
  if (l < r) {
    int mid = (l + r) / 2;
    build(v + v, l, mid);
    build(v + v + 1, mid + 1, r);
  }
}
int getMax(int v, int l, int r) {
  if (l <= t[v].l && t[v].r <= r) return t[v].mx;
  if (l > t[v].r || r < t[v].l) return 0;
  return max(getMax(v + v, l, r), getMax(v + v + 1, l, r));
}
void modify(int v, int p, int x) {
  int mid = (t[v].l + t[v].r) / 2;
  if (t[v].l < t[v].r) {
    if (p <= mid)
      modify(v + v, p, x);
    else
      modify(v + v + 1, p, x);
    t[v].mx = max(t[v + v].mx, t[v + v + 1].mx);
  } else {
    t[v].value = x;
    t[v].mx = x;
  }
}
int main() {
  int n, m, q;
  cin >> n >> m >> q;
  build(1, 1, n);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) cin >> a[i][j];
  for (int i = 1; i <= n; ++i) {
    int c = 0;
    int b = 0;
    for (int j = 1; j <= m; ++j) {
      if (a[i][j])
        ++c, b = max(b, c);
      else
        c = 0;
    }
    modify(1, i, b);
  }
  for (int cnt = 0; cnt < q; ++cnt) {
    int ii, jj;
    cin >> ii >> jj;
    a[ii][jj] = !a[ii][jj];
    int c = 0;
    int b = 0;
    for (int j = 1; j <= m; ++j) {
      if (a[ii][j])
        ++c, b = max(b, c);
      else
        c = 0;
    }
    modify(1, ii, b);
    cout << getMax(1, 1, n) << endl;
  }
  return 0;
}
