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