#include <bits/stdc++.h>
using namespace std;
const int maxn = 205;
int n, m;
string s[maxn];
int main() {
  int T;
  cin >> T;
  while (T--) {
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> s[i];
    }
    int ans = 0;
    int a = 0, b = 0, c = 0, d = 0;
    if (s[0][1] == s[1][0]) {
      int t = s[0][1];
      if (s[n - 2][n - 1] == t) {
        ans++;
        c = 1;
      }
      if (s[n - 1][n - 2] == t) {
        ans++;
        d = 1;
      }
    } else if (s[n - 1][n - 2] == s[n - 1][n - 2]) {
      int t = s[n - 1][n - 2];
      if (s[0][1] == t) {
        ans++;
        a = 1;
      }
      if (s[1][0] == t) {
        ans++;
        b = 1;
      }
    } else {
      ans = 2;
      a = 1;
      if (s[0][1] == s[n - 1][n - 2])
        c = 1;
      else
        d = 1;
    }
    cout << ans << endl;
    if (a) cout << 1 << " " << 2 << endl;
    if (b) cout << 2 << " " << 1 << endl;
    if (c) cout << n - 1 << " " << n << endl;
    if (d) cout << n << " " << n - 1 << endl;
  }
  return 0;
}
