#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<vector<char> > mat;
    for (int i = 0; i < n; i++) {
      vector<char> v(n);
      for (int j = 0; j < n; j++) cin >> v[j];
      mat.push_back(v);
    }
    if (mat[0][1] == mat[1][0]) {
      cout << (mat[n - 1][n - 2] == mat[0][1]) +
                  (mat[n - 2][n - 1] == mat[0][1])
           << "\n";
      if (mat[n - 2][n - 1] == mat[0][1]) cout << n - 1 << " " << n << "\n";
      if (mat[n - 1][n - 2] == mat[0][1]) cout << n << " " << n - 1 << "\n";
    } else {
      cout << 1 + (mat[n - 1][n - 2] != mat[n - 2][n - 1]) << "\n";
      if (mat[n - 1][n - 2] == mat[n - 2][n - 1]) {
        if (mat[n - 1][n - 2] == mat[0][1])
          cout << 1 << " " << 2 << "\n";
        else
          cout << 2 << " " << 1 << "\n";
      } else {
        cout << 1 << " " << 2 << "\n";
        if (mat[n - 2][n - 1] == mat[0][1])
          cout << n - 1 << " " << n << "\n";
        else
          cout << n << " " << n - 1 << "\n";
      }
    }
  }
  return 0;
}
