Square rotate(int count) {

      if (count == 0) return this;
      else {
        Square result = new Square(n);

        for (int r = 0; r < n; r++) for (int c = 0; c < n; c++) result.s[r][c] = s[n - 1 - c][r];

        return result.rotate(count - 1);
      }
    }
  public static void main(String[] arguments) {

    Scanner in = new Scanner(System.in);
    int n = in.nextInt();
    Square first = new Square(n, in);

    for (int count = 2; in.hasNext(); count++) {
      Square next = new Square(n, in);
      System.out.printf(
          "Square %d is %s square 1.%n",
          count,
          (first.equals(next.rotate(0))
                  || first.equals(next.rotate(0).hFlip())
                  || first.equals(next.rotate(1))
                  || first.equals(next.rotate(1).hFlip())
                  || first.equals(next.rotate(2))
                  || first.equals(next.rotate(2).hFlip())
                  || first.equals(next.rotate(3))
                  || first.equals(next.rotate(3).hFlip()))
              ? "identical to"
              : "distinct from");
    }
  }