#include <bits/stdc++.h>
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using namespace std;
const ll mod = 1e9 + 7;
const int N = 3e5 + 5;
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};
void test_case() {
  int n;
  cin >> n;
  vector<vector<char>> v(n, vector<char>(n));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> v[i][j];
    }
  }
  int c = 0;
  int r1 = -1, r2 = -1, c1 = -1, c2 = -1;
  if (v[0][1] == v[1][0]) {
    char smb = v[0][1];
    if (v[n - 1][n - 2] == smb) {
      c++;
      r1 = n - 1;
      c1 = n - 2;
    }
    if (v[n - 2][n - 1] == smb) {
      c++;
      r2 = n - 2;
      c2 = n - 1;
    }
  } else if (v[n - 1][n - 2] == v[n - 2][n - 1]) {
    char smb = v[n - 1][n - 2];
    if (v[0][1] == smb) {
      c++;
      r1 = 0;
      c1 = 1;
    }
    if (v[1][0] == smb) {
      c++;
      r2 = 1;
      c2 = 0;
    }
  } else {
    v[0][1] = v[1][0];
    char smb = v[0][1];
    if (v[n - 1][n - 2] == smb) {
      c++;
      r1 = n - 1;
      c1 = n - 2;
    }
    if (v[n - 2][n - 1] == smb) {
      c++;
      r2 = n - 2;
      c2 = n - 1;
    }
  }
  cout << c << "\n";
  if (c == 1) {
    if (r1 != -1) {
      cout << r1 + 1 << " " << c1 + 1 << "\n";
    } else {
      cout << r2 + 1 << " " << c2 + 1 << "\n";
    }
  } else if (c == 2) {
    cout << r1 + 1 << " " << c1 + 1 << "\n";
    cout << r2 + 1 << " " << c2 + 1 << "\n";
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int tc;
  cin >> tc;
  while (tc--) test_case();
  return 0;
}
