#include <bits/stdc++.h>
using namespace std;
string str[205], s[205];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    for (long long i = 0; i < n; i++) {
      cin >> str[i];
    }
    if (s[0][1] == s[1][0]) {
      if (s[n - 1][n - 2] == s[n - 2][n - 1]) {
        if (s[0][1] != s[n - 1][n - 2]) {
          cout << 0 << endl;
        } else {
          cout << 2 << endl;
          cout << 1 << " " << 2 << endl;
          cout << 2 << " " << 1 << endl;
        }
      } else {
        cout << 1 << endl;
        if (s[n - 1][n - 2] != s[0][1]) {
          cout << n - 1 << " " << n << endl;
        } else {
          cout << n << " " << n - 1 << endl;
        }
      }
    } else {
      if (s[n - 1][n - 2] == s[n - 2][n - 1]) {
        cout << 1 << endl;
        if (s[0][1] != s[n - 1][n - 2]) {
          cout << 2 << " " << 1 << endl;
        } else {
          cout << 1 << " " << 2 << endl;
        }
      } else {
        cout << 2 << endl;
        if (s[n - 1][n - 2] != '0') {
          cout << n - 1 << " " << n << endl;
        } else {
          cout << n - 1 << " " << n << endl;
        }
        if (s[1][0] != '0') {
          cout << 2 << " " << 1 << endl;
        } else {
          cout << 1 << " " << 2 << endl;
        }
      }
    }
  }
  return 0;
}
