#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int M = 1e6 + 5;
const int INF = 0x3f3f3f3f;
const long long LL_MAX = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + 7;
inline long long read() {
  long long res = 0;
  bool f = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = 1;
    ch = getchar();
  }
  while (ch <= '9' && ch >= '0') {
    res = (res << 3) + (res << 1) + ch - '0';
    ch = getchar();
  }
  return f ? (~res + 1) : res;
}
string s[202];
int main() {
  int t = read();
  while (t--) {
    int n = read();
    for (int i = 0; i < n; ++i) cin >> s[i];
    if (s[0][1] == s[1][0] && s[n - 1][n - 2] == s[n - 2][n - 1] &&
        s[1][0] == s[n - 1][n - 2]) {
      puts("2\n1 2\n2 1");
    } else if (s[0][1] == s[1][0] && s[n - 1][n - 2] == s[n - 2][n - 1]) {
      puts("0");
    } else if (s[0][1] == s[1][0] && s[n - 1][n - 2] != s[n - 2][n - 1]) {
      puts("1");
      if (s[n - 1][n - 2] == s[0][1]) {
        printf("%d %d\n", n, n - 1);
      } else
        printf("%d %d\n", n - 1, n);
    } else if (s[0][1] != s[1][0] && s[n - 1][n - 2] == s[n - 2][n - 1]) {
      puts("1");
      if (s[n - 1][n - 2] == s[0][1]) {
        printf("%d %d\n", 1, 2);
      } else
        printf("%d %d\n", 2, 1);
    } else {
      puts("2");
      puts("1 2");
      if (s[n - 1][n - 2] == s[0][1])
        printf("%d %d\n", n, n - 1);
      else
        printf("%d %d\n", n - 1, n);
    }
  }
  return 0;
}
