#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int prim(long long n) {
  long long i;
  if (n % 2 == 0 && n != 2) return 0;
  for (i = 3; i <= sqrt(n); i += 2)
    if (n % i == 0) return 0;
  return 1;
}
bool srt(long long *a, long long *b) {
  if (a[0] < b[0]) return true;
  return false;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t, *a, *b, c, d, m, n, x, y, z, w, cnt, l, h, k, i, j, ans = 0;
  double p, q, r;
  string s;
  cin >> t;
  while (t--) {
    cin >> n;
    vector<int> vv;
    string as[n];
    for (i = 0; i < n; i++) {
      cin >> as[i];
    }
    int aa[n][n];
    aa[0][1] = as[0][1] - '0';
    aa[1][0] = as[1][0] - '0';
    aa[n - 2][n - 1] = as[n - 2][n - 1] - '0';
    aa[n - 1][n - 2] = as[n - 1][n - 2] - '0';
    if (aa[0][1] == aa[1][0]) {
      if (aa[n - 2][n - 1] == aa[0][1]) {
        vv.push_back(n - 1);
        vv.push_back(n);
      }
      if (aa[n - 1][n - 2] == aa[0][1]) {
        vv.push_back(n);
        vv.push_back(n - 1);
      }
    } else if (aa[n - 2][n - 1] == aa[n - 1][n - 2]) {
      if (aa[0][1] == aa[n - 2][n - 1]) {
        vv.push_back(1);
        vv.push_back(2);
      }
      if (aa[1][0] == aa[n - 2][n - 1]) {
        vv.push_back(2);
        vv.push_back(1);
      }
    } else {
      aa[0][1] = aa[1][0];
      {
        vv.push_back(1);
        vv.push_back(2);
      }
      if (aa[n - 2][n - 1] == aa[0][1]) {
        vv.push_back(n - 1);
        vv.push_back(n);
      } else if (aa[n - 1][n - 2] == aa[0][1]) {
        vv.push_back(n);
        vv.push_back(n - 1);
      }
    }
    ans = vv.size();
    cout << ans << endl;
    for (i = 0; i < vv.size(); i = i + 2)
      cout << vv[i] << " " << vv[i + 1] << endl;
  }
}
