#include <bits/stdc++.h>
using namespace std;
inline int read() {
  register int x = 0, f = 0, ch = getchar();
  while ('0' > ch || ch > '9') f ^= ch == '-', ch = getchar();
  while ('0' <= ch && ch <= '9')
    x = (x << 1) + (x << 3) + (ch ^ '0'), ch = getchar();
  return f ? -x : x;
}
int t, n;
struct node {
  string s;
} a[210];
int main() {
  t = read();
  while (t--) {
    n = read();
    int ans = 0;
    for (int i = 1; i <= n; i++) cin >> a[i].s;
    if (a[1].s[1] == a[2].s[0]) {
      if (a[n].s[n - 2] == a[1].s[1]) ++ans;
      if (a[n - 1].s[n - 1] == a[1].s[1]) ++ans;
      printf("%d\n", ans);
      if (a[n].s[n - 2] == a[1].s[1]) printf("%d %d\n", n, n - 1);
      if (a[n - 1].s[n - 1] == a[1].s[1]) printf("%d %d\n", n - 1, n);
    } else {
      if (a[n].s[n - 2] == a[n - 1].s[n - 1]) {
        puts("1");
        if (a[n].s[n - 2] == a[1].s[1])
          puts("2 1");
        else
          puts("1 2");
        continue;
      }
      puts("2");
      if (a[n].s[n - 2] == a[1].s[1])
        printf("%d %d\n1 1\n", n, n - 1);
      else
        printf("%d %d\n1 1\n", n - 1, n);
    }
  }
  return 0;
}
