#include <bits/stdc++.h>
using namespace std;
const int maxn = 100001, inf = 2147483647;
const long long mod = 1 ? 998244353 : 1000000007, linf = 9223372036854775807;
const double pi = acos(-1);
inline long long mi(long long a, long long b) {
  a %= mod;
  long long u = 1;
  while (b) {
    if (b & 1) u = u * a % mod;
    a = a * a % mod, b >>= 1;
  }
  return u;
}
inline long long gcd(long long a, long long b) {
  long long c = a % b;
  while (c) a = b, b = c, c = a % b;
  return b;
}
inline void mem(int* a, int p = 0, int len = maxn) {
  for (register int i = 0; i < len; i++) a[i] = p;
}
int a[maxn];
string s[201];
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  long long t, x, y, c[7], cc[7];
  cin >> t;
  while (t--) {
    cin >> x;
    for (int i = 0; i < x; i++) cin >> s[i];
    vector<pair<int, int>> v;
    if (s[0][1] == s[1][0]) {
      if (s[x - 1][x - 2] == s[0][1]) v.push_back({x, x - 1});
      if (s[x - 2][x - 1] == s[0][1]) v.push_back({x - 1, x});
    } else {
      if (s[x - 1][x - 2] == s[x - 2][x - 1]) {
        if (s[0][1] == s[x - 1][x - 2]) v.push_back({1, 2});
        if (s[1][0] == s[x - 1][x - 2]) v.push_back({2, 1});
      } else {
        if (s[0][1] == s[x - 1][x - 2])
          v.push_back({1, 2}), v.push_back({x, x - 1});
        else
          v.push_back({1, 2}), v.push_back({x - 1, x});
      }
    }
    cout << v.size() << endl;
    for (int i = 0; i < v.size(); i++)
      cout << v[i].first << ' ' << v[i].second << endl;
  }
}
