#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  scanf("%d", &n);
  string s[n + 1];
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  char a = s[0][1];
  char b = s[1][0];
  char c = s[n - 1][n - 2];
  char d = s[n - 2][n - 1];
  if (a == b && c == d && a != c)
    cout << 0 << "\n";
  else if (a != b && c != d) {
    cout << 2 << "\n";
    if (a == '0')
      printf("1 2\n");
    else
      printf("2 1\n");
    if (c == '0')
      printf("%d %d\n", n, n - 1);
    else
      printf("%d %d\n", n - 1, n);
  } else {
    printf("1\n");
    if (a == b) {
      if (a == c)
        printf("%d %d\n", n, n - 1);
      else
        printf("%d %d\n", n - 1, n);
    } else {
      if (a == c)
        printf("1 2\n");
      else
        printf("2 1\n");
    }
  }
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) solve();
  return 0;
}
