#include <bits/stdc++.h>
using namespace std;
#pragma GCC push_options
#pragma GCC optimize("unroll-loops")
int dr[] = {0, 1, -1, 0};
int dc[] = {1, 0, 0, -1};
bool safe(int r, int c, int n) {
  if (r < 0 || c < 0 || r > n - 1 || c > n - 1) {
    return 0;
  }
  return 1;
}
void solve(vector<string> &a, char index, int r, int c, bool &res) {
  int n = a.size();
  if (r < 0 || c < 0 || r > n - 1 || c > n - 1) {
    return;
  }
  char temp = a[r][c];
  a[r][c] = 'V';
  for (int i = 0; i < 4; i++) {
    int R = r + dr[i];
    int C = c + dc[i];
    if (safe(R, C, n) && a[R][C] == 'F') {
      res = 1;
      a[r][c] = temp;
      return;
    }
    if (safe(R, C, n) && a[R][C] == index) {
      solve(a, index, R, C, res);
    }
  }
  a[r][c] = temp;
}
void print(vector<string> &a) {
  int n = a.size();
  for (long long i = 0; i < n; i++) {
    cout << a[i] << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<string> a(n);
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
    }
    vector<int> res;
    if (a[0][1] == a[1][0]) {
      if (a[n - 1][n - 2] == a[0][1]) {
        res.push_back(n - 1 + 1);
        res.push_back(n - 2 + 1);
      }
      if (a[n - 2][n - 1] == a[0][1]) {
        res.push_back(n - 2 + 1);
        res.push_back(n - 1 + 1);
      }
      if (res.size() == 0) {
        cout << 0 << endl;
      } else if (res.size() == 2) {
        cout << 1 << endl;
        cout << res[0] << " " << res[1] << endl;
      } else {
        cout << 2 << endl;
        cout << res[0] << " " << res[1] << endl
             << res[2] << " " << res[3] << endl;
      }
    } else {
      bool res1 = 0;
      bool res2 = 0;
      solve(a, a[0][1], 0, 1, res1);
      solve(a, a[1][0], 1, 0, res2);
      if (res1 == 1 && res2 == 1) {
        res.push_back(n - 1 + 1);
        res.push_back(n - 2 + 1);
        res.push_back(n - 1 + 1);
        res.push_back(n - 2 + 1);
      } else if (res2 == 1) {
        char index = a[1][0];
        if (a[n - 1][n - 2] == index) {
          res.push_back(n - 1 + 1);
          res.push_back(n - 2 + 1);
        }
        if (a[n - 2][n - 1] == index) {
          res.push_back(n - 2 + 1);
          res.push_back(n - 1 + 1);
        }
      } else if (res1 == 1) {
        char index = a[0][1];
        if (a[n - 1][n - 2] == index) {
          res.push_back(n - 1 + 1);
          res.push_back(n - 2 + 1);
        }
        if (a[n - 2][n - 1] == index) {
          res.push_back(n - 2 + 1);
          res.push_back(n - 1 + 1);
        }
      }
      if (res.size() == 0) {
        cout << 0 << endl;
      } else if (res.size() == 2) {
        cout << 1 << endl;
        cout << res[0] << " " << res[1] << endl;
      } else {
        cout << 2 << endl;
        cout << res[0] << " " << res[1] << endl
             << res[2] << " " << res[3] << endl;
      }
    }
  }
  return 0;
}
