#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  char matrix[n + 1][n + 1];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> matrix[i][j];
    }
  }
  char pos12 = matrix[0][1];
  char pos21 = matrix[1][0];
  char poslu = matrix[n - 2][n - 1];
  char poslr = matrix[n - 1][n - 2];
  if (pos12 == pos21 && poslr == poslu) {
    if (pos12 != poslu) {
      cout << 0 << endl;
      return;
    }
    cout << 2 << endl;
    cout << 1 << " " << 2 << endl;
    cout << 2 << " " << 1 << endl;
    return;
  }
  int cnt = 0;
  if (pos12 != pos21) cnt++;
  if (poslu != poslr) cnt++;
  cout << cnt << endl;
  if (pos12 == '1') {
    cout << 1 << " " << 2 << endl;
  }
  if (pos21 == '1') {
    cout << 2 << " " << 1 << endl;
  }
  if (poslu == '0') {
    cout << n - 1 << " " << n << endl;
  }
  if (poslr == '0') {
    cout << n << " " << n - 1 << endl;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int T;
  T = 1;
  cin >> T;
  while (T--) {
    solve();
  }
  return 0;
}
