#include <bits/stdc++.h>
using namespace std;
void solve(long long t) {
  long long n;
  cin >> n;
  string s[n];
  for (long long i = 0; i < n; i++) cin >> s[i];
  if (n >= 3) {
    if (s[0][1] == '1' and s[1][0] == '1' and s[n - 1][n - 2] == '1' and
        s[n - 2][n - 1] == '1') {
      cout << 2 << "\n";
      cout << 1 << " " << 2 << "\n";
      cout << 2 << " " << 1 << "\n";
      return;
    } else if (s[0][1] == '1' and s[1][0] == '1' and s[n - 1][n - 2] == '0' and
               s[n - 2][n - 2] == '0') {
      cout << 0 << "\n";
      return;
    } else if (s[0][1] == '1' and s[1][0] == '1' and s[n - 1][n - 2] == '1' and
               s[n - 2][n - 1] == '0') {
      cout << 1 << "\n";
      cout << n << " " << n - 1 << "\n";
      return;
    } else if (s[0][1] == '1' and s[1][0] == '1' and s[n - 1][n - 2] == '0' and
               s[n - 2][n - 1] == '1') {
      cout << 1 << "\n";
      cout << n - 1 << " " << n << "\n";
      return;
    } else if (s[0][1] == '0' and s[1][0] == '0' and s[n - 1][n - 2] == '1' and
               s[n - 2][n - 1] == '1') {
      cout << 0 << "\n";
      return;
    } else if (s[0][1] == '0' and s[1][0] == '0' and s[n - 1][n - 2] == '0' and
               s[n - 2][n - 1] == '0') {
      cout << 2 << "\n";
      cout << 1 << " " << 2 << "\n";
      cout << 2 << " " << 1 << "\n";
      return;
    } else if (s[0][1] == '0' and s[1][0] == '0' and s[n - 1][n - 2] == '1' and
               s[n - 2][n - 1] == '0') {
      cout << 1 << "\n";
      cout << n - 1 << " " << n << "\n";
      return;
    } else if (s[0][1] == '0' and s[1][0] == '1' and s[n - 1][n - 2] == '0' and
               s[n - 2][n - 1] == '1') {
      cout << 2 << "\n";
      cout << 1 << " " << 2 << "\n";
      cout << n - 1 << " " << n << "\n";
      return;
    } else if (s[0][1] == '0' and s[1][0] == '1' and s[n - 1][n - 2] == '1' and
               s[n - 2][n - 1] == '1') {
      cout << 0 << "\n";
      return;
    } else if (s[0][1] == '0' and s[1][0] == '1' and s[n - 1][n - 2] == '0' and
               s[n - 2][n - 1] == '0') {
      cout << 1 << "\n";
      cout << 1 << " " << 2 << "\n";
      return;
    } else if (s[0][1] == '0' and s[1][0] == '1' and s[n - 1][n - 2] == '1' and
               s[n - 2][n - 1] == '0') {
      cout << 2 << "\n";
      cout << 1 << " " << 2 << "\n";
      cout << n << " " << n - 1 << "\n";
      return;
    } else if (s[0][1] == '0' and s[1][0] == '1' and s[n - 1][n - 2] == '0' and
               s[n - 2][n - 1] == '1') {
      cout << 2 << "\n";
      cout << 1 << " " << 2 << "\n";
      cout << n - 1 << " " << n << "\n";
      return;
    } else if (s[0][1] == '1' and s[1][0] == '0' and s[n - 1][n - 2] == '1' and
               s[n - 2][n - 1] == '1') {
      cout << 1 << "\n";
      cout << 1 << " " << 2 << "\n";
      return;
    } else if (s[0][1] == '1' and s[1][0] == '0' and s[n - 1][n - 2] == '0' and
               s[n - 2][n - 1] == '0') {
      cout << 1 << "\n";
      cout << 2 << " " << 1 << "\n";
      return;
    } else if (s[0][1] == '1' and s[1][0] == '0' and s[n - 1][n - 2] == '1' and
               s[n - 2][n - 1] == '0') {
      cout << 2 << "\n";
      cout << 1 << " " << 2 << "\n";
      cout << n - 1 << " " << n << "\n";
      return;
    } else if (s[0][1] == '1' and s[1][0] == '0' and s[n - 1][n - 2] == '0' and
               s[n - 2][n - 1] == '1') {
      cout << 2 << "\n";
      cout << 1 << " " << 2 << "\n";
      cout << n << " " << n - 1 << "\n";
      return;
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  for (long long tc = 1; tc <= t; tc++) {
    solve(t);
  }
  return 0;
}
