#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 9;
int main() {
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(10);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    vector<string> s(n + 1);
    for (int i = 0; i < n; i++) cin >> s[i];
    long long x1 = s[0][1] - '0', x2 = s[1][0] - '0';
    long long y1 = s[n - 2][n - 1] - '0', y2 = s[n - 1][n - 2] - '0';
    cout << "["
         << "x1"
         << ": " << x1 << "]"
         << "  ["
         << "x2"
         << ": " << x2 << "]"
         << "  ["
         << "y1"
         << ": " << y1 << "]"
         << "  ["
         << "y2"
         << ": " << y2 << "]\n";
    if (x1 == x2 && y1 == y2 && y1 == x1) {
      cout << "2\n";
      cout << 0 + 1 << " " << 1 + 1 << "\n";
      cout << 1 + 1 << " " << 0 + 1 << "\n";
      continue;
    }
    if (x1 == x2) {
      if (y1 == y2) {
        cout << "0\n";
        continue;
      }
      cout << "1\n";
      if (y1 == x1)
        cout << n - 2 + 1 << " " << n - 1 + 1 << "\n";
      else
        cout << n - 1 + 1 << " " << n - 2 + 1 << "\n";
      continue;
    }
    if (y1 == y2) {
      if (x1 == x2) {
        cout << "0\n";
        continue;
      }
      cout << "1\n";
      if (x1 == y1)
        cout << 0 + 1 << " " << 1 + 1 << "\n";
      else
        cout << 1 + 1 << " " << 0 + 1 << "\n";
      continue;
    }
    if (x1 == y1 && x2 == y2) {
      cout << "2\n";
      cout << 1 + 1 << " " << 0 + 1 << "\n";
      cout << n - 2 + 1 << " " << n - 1 + 1 << "\n";
      continue;
    }
    cout << "2\n";
    cout << 0 + 1 << " " << 1 + 1 << "\n";
    cout << n - 2 + 1 << " " << n - 1 + 1 << "\n";
    continue;
  }
}
