#include <bits/stdc++.h>
using namespace std;
int n, m, q;
int grid[505][505];
int answers[505];
void precompute() {
  for (int i = 0; i < n; ++i) {
    int ans = 0, a = 0;
    for (int j = 0; j < m; ++j) {
      if (grid[i][j] == 1)
        ++a;
      else {
        ans = max(ans, a);
        a = 0;
      }
    }
    answers[i] = max(ans, a);
    ;
  }
}
int getMaximum(int i) {
  int answer = 0;
  int ans = 0, a = 0;
  for (int j = 0; j < m; ++j) {
    if (grid[i][j] == 1)
      ++a;
    else {
      ans = max(ans, a);
      a = 0;
    }
  }
  ans = max(ans, a);
  answer = max(answer, ans);
  answers[i] = answer;
  return *max_element(answers, answers + n);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m >> q;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) {
      cin >> grid[i][j];
    }
  precompute();
  while (q--) {
    int i, j;
    cin >> i >> j;
    --i;
    --j;
    if (grid[i][j] == 1) {
      grid[i][j] = 0;
    } else {
      grid[i][j] = 1;
    }
    cout << getMaximum(i) << '\n';
  }
}
