#include <bits/stdc++.h>
using namespace std;
char a[300][300];
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t, n;
  cin >> t;
  while (t--) {
    bool flag1 = false, flag2 = false, flag3 = false, flag4 = false;
    cin >> n;
    int cnt = 0;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++) cin >> a[i][j];
    if (a[1][2] == '1') {
      cnt++;
      flag1 = true;
    }
    if (a[2][1] == '1') {
      cnt++;
      flag2 = true;
    }
    if (a[n - 1][n] == '1') {
      cnt++;
      flag3 = true;
    }
    if (a[n][n - 1] == '1') {
      cnt++;
      flag4 = true;
    }
    if (cnt == 4 || cnt == 0) {
      cout << 2 << endl;
      cout << 1 << " " << 2 << endl << 2 << " " << 1 << endl;
    } else if (cnt == 3) {
      cout << 1 << endl;
      if (flag1 ^ flag2)
        if (flag1)
          cout << 1 << " " << 2 << endl;
        else
          cout << 2 << " " << 1 << endl;
      else if (flag3)
        cout << n - 1 << " " << n << endl;
      else
        cout << n << " " << n - 1 << endl;
    } else if (cnt == 1) {
      cout << 1 << endl;
      if (flag1 ^ flag2)
        if (flag1)
          cout << 2 << " " << 1 << endl;
        else
          cout << 1 << " " << 2 << endl;
      else if (flag3)
        cout << n << " " << n - 1 << endl;
      else
        cout << n - 1 << " " << n << endl;
    } else {
      if (flag1 ^ flag2) {
        cout << 2 << endl;
        if (flag1)
          cout << 1 << " " << 2 << endl;
        else
          cout << 2 << " " << 1 << endl;
        if (flag3)
          cout << n - 1 << " " << n << endl;
        else
          cout << n << " " << n - 1 << endl;
      } else {
        cout << 0 << endl;
      }
    }
  }
  return 0;
}
