#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:360777216")
using LL = long long;
int M = 1000000007;
int INF = INT_MAX - 1000;
LL LLINF = 1e17;
int P = 31;
using namespace std;
LL t, n, m, x, k, p, f, a, b;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  for (int(ii) = (0); (ii) < (t); ++(ii)) {
    cin >> n;
    vector<string> tab(n);
    for (int(i) = (0); (i) < (n); ++(i)) {
      cin >> tab[i];
    }
    string s1 = "", s2 = "";
    s1.push_back(tab[0][1]);
    s1.push_back(tab[1][0]);
    s2.push_back(tab[n - 1][n - 2]);
    s2.push_back(tab[n - 2][n - 1]);
    if (s1 == "00" && s2 == "11") {
      cout << 0 << endl;
      continue;
    }
    if (s1 == "11" && s2 == "00") {
      cout << 0 << endl;
      continue;
    }
    if (s1 == "00") {
      if (s2 == "00")
        cout << 2 << endl << "1 2" << endl << "2 1" << endl;
      else if (s2 == "01")
        cout << 1 << endl << n << " " << n - 1 << endl;
      else if (s2 == "10")
        cout << 1 << endl << n - 1 << " " << n << endl;
    } else if (s1 == "01") {
      if (s2 == "00")
        cout << 1 << endl << "1 2" << endl;
      else if (s2 == "01")
        cout << 2 << "2 1" << endl << n << " " << n - 1 << endl;
      else if (s2 == "10")
        cout << 2 << "2 1" << endl << n - 1 << " " << n << endl;
      else
        cout << 1 << endl << "2 1" << endl;
    } else if (s1 == "10") {
      if (s2 == "00")
        cout << 1 << endl << "2 1" << endl;
      else if (s2 == "10")
        cout << 2 << "2 1" << endl << n << " " << n - 1 << endl;
      else if (s2 == "01")
        cout << 2 << "2 1" << endl << n - 1 << " " << n << endl;
      else
        cout << 1 << endl << "1 2" << endl;
    } else {
      if (s2 == "10")
        cout << 1 << "1 2" << endl;
      else if (s2 == "01")
        cout << 2 << "2 1" << endl;
      else if (s2 == "11")
        cout << 2 << endl << "1 2" << endl << "2 1" << endl;
    }
  }
  return 0;
}
