#include <bits/stdc++.h>
using namespace std;
void GO() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
const int N = 5e2 + 100, OO = 0x3f3f3f3f;
int mn = OO, mx = -OO;
int arr[N][N], n, m, q;
int values[N];
void solve(int i) {
  int res = 0;
  values[i] = 0;
  for (int j = 1; j <= m; ++j) {
    if (arr[i][j])
      res++;
    else
      res = 0;
    values[i] = max(values[i], res);
  }
}
int main() {
  GO();
  cin >> n >> m >> q;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) cin >> arr[i][j];
    solve(i);
  }
  while (q--) {
    int l, r;
    mx = -OO;
    cin >> l >> r;
    arr[l][r] ^= 1;
    solve(l);
    for (int i = 1; i <= n; ++i) mx = max(mx, values[i]);
    cout << mx << endl;
  }
  return 0;
}
