#include <bits/stdc++.h>
using namespace std;
int t, n;
char s[207][207];
int main() {
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        cin >> s[i][j];
      }
    }
    int ok1 = 0, ok2 = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        if (s[i][j] == '0') ok1 = 1;
        if (s[i][j] == '1') ok2 = 1;
      }
    }
    if (s[1][2] != s[2][1]) {
      cout << "2" << endl;
      cout << "1 2" << endl;
    } else if (s[n - 1][n] != s[n][n - 1]) {
      cout << "2" << endl;
      cout << n - 1 << " " << n << endl;
    } else {
      if (ok1 == 0 || ok2 == 0) {
        cout << "2" << endl;
        cout << "1 2" << endl;
        cout << "2 1" << endl;
      } else
        cout << "0" << endl;
    }
  }
}
