#include <bits/stdc++.h>
using namespace std;
const long long M = 1e9 + 7;
const long long MAXN = 1e6 + 7;
const long double pi = acos(-1);
inline long long read() {
  long long x = 0, ff = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') ff = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  return x * ff;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long pow1(long long p, long long d, long long P) {
  return d ? (pow1(p * p % P, d >> 1, P) * (d & 1 ? p % P : 1)) % P : 1;
}
vector<long long> prime;
bool is_composite[MAXN];
void sieve(long long n) {
  std::fill(is_composite, is_composite + n, false);
  for (long long i = 2; i < n; ++i) {
    if (!is_composite[i]) prime.push_back(i);
    for (long long j = 0; j < (long long)prime.size() && i * prime[j] < n;
         ++j) {
      is_composite[i * prime[j]] = true;
      if (i % prime[j] == 0) break;
    }
  }
}
long long modInverse(long long a, long long m) {
  long long m0 = m, y = 0, x = 1;
  if (m == 1) return 0;
  while (a > 1) {
    long long q = a / m, t = m;
    m = a % m;
    a = t;
    t = y;
    y = x - q * y;
    x = t;
  }
  if (x < 0) x += m0;
  return x;
}
void doit() {
  long long n = read();
  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 p, q, r, s;
  p = a[0][1] ^ 48;
  q = a[1][0] ^ 48;
  r = a[n - 2][n - 1] ^ 48;
  s = a[n - 1][n - 1] ^ 48;
  if (p && q) {
    if (!r && !s)
      cout << 0;
    else if (r && !s) {
      cout << "1\n";
      cout << n - 1 << ' ' << n << '\n';
    } else if (!r && s) {
      cout << "1\n";
      cout << n << ' ' << n - 1 << '\n';
    } else {
      cout << "2\n";
      cout << n - 1 << ' ' << n << '\n';
      cout << n << ' ' << n - 1 << '\n';
    }
  } else if (!p && q) {
    if (!r && !s) {
      cout << "1\n";
      cout << "1 2\n";
    } else if (r && !s) {
      cout << "2\n";
      cout << "2 1\n";
      cout << n << ' ' << n - 1 << '\n';
    } else if (!r && s) {
      cout << "2\n";
      cout << "2 1\n";
      cout << n - 1 << ' ' << n << '\n';
    } else {
      cout << "1\n";
      cout << "2 1\n";
    }
  } else if (p && !q) {
    if (!r && !s) {
      cout << "1\n";
      cout << "2 1\n";
    } else if (r && !s) {
      cout << "2\n";
      cout << "2 1\n";
      cout << n - 1 << ' ' << n << '\n';
    } else if (!r && s) {
      cout << "2\n";
      cout << "2 1\n";
      cout << n << ' ' << n - 1 << '\n';
    } else {
      cout << "1\n";
      cout << "1 2\n";
    }
  } else {
    if (!r && !s) {
      cout << "2\n";
      cout << n - 1 << ' ' << n << '\n';
      cout << n << ' ' << n - 1 << '\n';
    } else if (r && !s) {
      cout << "1\n";
      cout << n << ' ' << n - 1 << '\n';
    } else if (!r && s) {
      cout << "1\n";
      cout << n - 1 << ' ' << n << '\n';
    } else {
      cout << "0";
    }
  }
}
int main() {
  for (long long t = read(); t--; cout << '\n') doit();
  return 0;
}
