#include <iostream>
#include <vector>
using namespace std;


typedef vector<int> Fila;
typedef vector<Fila> Quadrat;


bool es_llati(const Quadrat& q);


int main() {
  int n;
  while (cin >> n) {
    Quadrat q(n, Fila(n));
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < n; ++j) cin >> q[i][j];
    cout << es_llati(q) << endl;

    int c;
    cin >> c;
    while (c--) {
      int i, j;
      cin >> i >> j;
      cin >> q[i][j];
      cout << es_llati(q) << endl;
    }
  }
  return 0;
}
