#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e3 + 5;
const long long p = 31;
void solve() {
  long long n;
  cin >> n;
  char a[n][n];
  for (long long i = (0); i < (n); i++)
    for (long long j = (0); j < (n); j++) cin >> a[i][j];
  long long x, y, z, w;
  x = a[0][1] - '0';
  y = a[1][0] - '0';
  w = a[n - 1][n - 2] - '0';
  z = a[n - 2][n - 1] - '0';
  if ((x + y + z + w) == 4) {
    cout << "2\n";
    cout << "1 2\n";
    cout << "2 1\n";
  } else if ((x + y + z + w) == 0) {
    cout << "2\n";
    cout << "1 2\n";
    cout << "2 1\n";
  } else if ((x + y) == 2 and (z + w) == 1) {
    cout << "1\n";
    if (z == 1)
      cout << n - 1 << ' ' << n << '\n';
    else
      cout << n << ' ' << n - 1 << '\n';
  } else if ((x + y) == 1 and (z + w) == 2) {
    cout << "1\n";
    if (y == 1)
      cout << "2 1" << '\n';
    else
      cout << "1 2" << '\n';
  } else if ((x + y) == 0 and (z + w) == 1) {
    cout << "1\n";
    if (z == 1)
      cout << n - 1 << ' ' << n << '\n';
    else
      cout << n << ' ' << n - 1 << '\n';
  } else if ((x + y) == 1 and (z + w) == 0) {
    cout << "1\n";
    if (x == 0)
      cout << "1 2" << '\n';
    else
      cout << "2 1" << '\n';
  } else if ((x + y) == 1 and (z + w) == 1) {
    cout << "2\n";
    if (x == 1 and z == 1) {
      cout << "1 2\n";
      cout << n - 1 << ' ' << n << '\n';
    } else if (x == 1 and w == 1) {
      cout << "1 2\n";
      cout << n << ' ' << n - 1 << '\n';
    } else if (y == 1 and z == 1) {
      cout << "2 1\n" << n - 1;
      cout << ' ' << n << '\n';
    } else if (y == 1 and w == 1) {
      cout << "2 1\n";
      cout << n << ' ' << n - 1 << '\n';
    }
  } else if ((x + y) == 2 and (z + w) == 0 || (x + y) == 0 and (z + w) == 2)
    cout << "0\n";
}
int32_t main() {
  long long t;
  cin >> t;
  while (t--) solve();
}
