#include <bits/stdc++.h>
using namespace std;
int a[505][505];
int n, m, i, j, q, ma, num;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << setprecision(17);
  cin >> n >> m >> q;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> a[i][j];
  while (q--) {
    ma = 0;
    cin >> i >> j;
    a[i][j] = 1 - a[i][j];
    for (int i = 1; i <= n; i++, num = 0)
      for (int j = 1; j <= m; j++) {
        if (a[i][j] == 1)
          num++;
        else
          num = 0;
        if (num > ma) ma = num;
      }
    cout << ma << "\n";
  }
  return 0;
}
