#include <bits/stdc++.h>
using namespace std;
int solve(int grid[][510], int n, int m, pair<int, int> q) {
  grid[q.first - 1][q.second - 1] ^= 1;
  int best = -1;
  for (int i = 0; i < n; i++) {
    int count = 0;
    for (int j = 0; j < m; j++) {
      if (grid[i][j])
        count++;
      else
        count = 0;
      best = max(count, best);
    }
  }
  return best;
}
int main() {
  int n, m, q;
  cin >> n >> m >> q;
  int grid[510][510];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> grid[i][j];
  for (int i = 0; i < q; i++) {
    pair<int, int> query;
    cin >> query.first >> query.second;
    auto res = solve(grid, n, m, query);
    cout << res << endl;
  }
  return 0;
}
