#include <bits/stdc++.h>
using namespace std;
long long i = 0, j = 0, k = 0, a, b, c, d, e, f, g, h, l, m, n, o, p, q, r, s,
          t = 1, u, v, w, x, y, z, maxx = INT_MIN, minn = INT_MAX, ans = 0,
          sum = 0, flag = 0, cnt = 0;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> t;
  while (t--) {
    cin >> n;
    string second[n];
    for (long long i = 0; i < (n); i++) {
      cin >> second[i];
    }
    ans = 0;
    if (second[0][1] == second[1][0]) {
      if (second[n - 1][n - 2] == second[n - 2][n - 1]) {
        if (second[0][1] == second[n - 2][n - 1]) {
          ans = 2;
          cout << ans << endl;
          cout << 1 << " " << 2 << endl;
          cout << 2 << " " << 1 << endl;
        } else {
          ans = 0;
          cout << ans << endl;
        }
      } else {
        ans = 1;
        cout << ans << endl;
        if (second[0][1] == second[n - 2][n - 1]) {
          cout << n - 1 << " " << n << endl;
        } else {
          cout << n << " " << n - 1 << endl;
        }
      }
    } else {
      if (second[n - 1][n - 2] == second[n - 2][n - 1]) {
        ans = 1;
        cout << ans << endl;
        if (second[0][1] == second[n - 2][n - 1]) {
          cout << 1 << " " << 2 << endl;
        } else {
          cout << 2 << " " << 1 << endl;
        }
      } else {
        ans = 2;
        cout << ans << endl;
        if (second[0][1] == second[n - 2][n - 1]) {
          cout << 1 << " " << 2 << endl;
          cout << n - 1 << " " << n << endl;
        } else {
          cout << 1 << " " << 2 << endl;
          cout << n << " " << n - 1 << endl;
        }
      }
    }
  }
  return 0;
}
