#include <bits/stdc++.h>
using namespace std;
long long int i, j, n, m, k, f = 0, c = 0;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int tc;
  cin >> tc;
  while (tc--) {
    cin >> n;
    char a[n][n];
    for (i = 0; i < n; i++)
      for (j = 0; j < n; j++) cin >> a[i][j];
    long long int p1 = a[0][1] - '0', p2 = a[1][0] - '0',
                  p3 = a[n - 2][n - 1] - '0', p4 = a[n - 1][n - 2] - '0';
    if (p1 + p2 == 0) {
      cout << 2 - p3 - p4 << "\n";
      if (p3 == 0) cout << n - 1 << " " << n << "\n";
      if (p4 == 0) cout << n << " " << n - 1 << "\n";
      continue;
    }
    if (p1 + p2 == 2) {
      cout << p3 + p4 << "\n";
      if (p3 == 1) cout << n - 1 << " " << n << "\n";
      if (p4 == 1) cout << n << " " << n - 1 << "\n";
      continue;
    }
    if (p3 + p4 == 0) {
      cout << 2 - p1 - p2 << "\n";
      if (p1 == 0) cout << 1 << " " << 2 << "\n";
      if (p2 == 0) cout << 2 << " " << 1 << "\n";
      continue;
    }
    if (p3 + p4 == 2) {
      cout << p1 + p2 << "\n";
      if (p1 == 1) cout << 1 << " " << 2 << "\n";
      if (p2 == 1) cout << 2 << " " << 1 << "\n";
      continue;
    }
    if (p2 + p4 == 0 || p2 + p4 == 2) {
      cout << 2 << "\n"
           << "2 1"
           << "\n"
           << n - 1 << " " << n << "\n";
      continue;
    }
    cout << 2 << "\n"
         << "1 2\n"
         << n << " " << n - 1 << "\n";
  }
}
