#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    char c[n][n];
    for (long long int i = 0; i < n; i++) {
      for (long long int j = 0; j < n; j++) {
        cin >> c[i][j];
      }
    }
    char p, q, r, s;
    p = c[0][1];
    q = c[1][0];
    r = c[n - 2][n - 1];
    s = c[n - 1][n - 2];
    vector<pair<long long int, long long int> > v;
    if (p == q) {
      if (p == r) {
        v.push_back({n - 1, n});
      }
      if (p == s) {
        v.push_back({n, n - 1});
      }
      cout << v.size() << endl;
      for (auto g : v) cout << g.first << " " << g.second << endl;
    } else {
      if (s == r) {
        if (p != s)
          v.push_back({1, 2});
        else if (q != s)
          v.push_back({2, 1});
      } else {
        if (p == s) v.push_back({1, 2}), v.push_back({n, n - 1});
        if (p == r) v.push_back({1, 2}), v.push_back({n - 1, n});
      }
      cout << v.size() << endl;
      for (auto g : v) cout << g.first << " " << g.second << endl;
    }
  }
  return 0;
}
