import java.util.Scanner;

class Main {

  public static void main(String[] args) {
    final Scanner sc = new Scanner(System.in);
    while (sc.hasNextInt()) {
      int n = sc.nextInt();
      int[][] mat = new int[n][n];
      for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j) mat[i][j] = sc.nextInt();
      System.out.println(Solution.esSimetrica(mat) ? "1" : "0");

      int q = sc.nextInt();
      for (int r = 0; r < q; ++r) {
        int m = sc.nextInt();
        int[] I = new int[m];
        int[] J = new int[m];
        int[] C = new int[m];
        for (int k = 0; k < m; ++k) {
          I[k] = sc.nextInt();
          J[k] = sc.nextInt();
          int v = sc.nextInt();
          C[k] = mat[I[k]][J[k]];
          mat[I[k]][J[k]] = v;
        }
        System.out.println(Solution.esSimetrica(mat) ? "1" : "0");
        for (int k = 0; k < m; ++k) mat[I[k]][J[k]] = C[k];
      }
    }
  }
}
