#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    vector<string> g(n);
    for (long long i = 0; i < n; i++) cin >> g[i];
    long long grid[n][n];
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j < n; j++) {
        if ((i == 0 && j == 0) || (i == n - 1 && j == n - 1)) continue;
        grid[i][j] = g[i][j] - '0';
      }
    }
    long long a = grid[0][1], b = grid[1][0], c = grid[n - 1][n - 2],
              d = grid[n - 2][n - 1];
    if (a == b && c == d) {
      if (a == d) {
        cout << 2 << endl;
        cout << "1 2" << endl;
        cout << "2 1" << endl;
      } else {
        cout << 0 << endl;
      }
    } else if ((a != b && c == d) || (a == b && c != d)) {
      if (a != b && c == d) {
        if (a == c) {
          cout << 1 << endl;
          cout << "1 2" << endl;
        } else {
          cout << 1 << endl;
          cout << "2 1" << endl;
        }
      } else {
        if (c == a) {
          cout << 1 << endl;
          cout << n << " " << n - 1 << endl;
        } else {
          cout << 1 << endl;
          cout << n - 1 << " " << n << endl;
        }
      }
    } else
      cout << 0 << endl;
  }
  return 0;
}
