#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    string a[n];
    for (long long int i = 0; i < n; i++) {
      cin >> a[i];
    }
    if (a[0][1] == a[1][0] && (a[0][1] == '0')) {
      long long int ans = 0;
      vector<pair<long long int, long long int>> v;
      if (a[n - 1][n - 2] == '0') {
        ans++;
        v.push_back(make_pair(n, n - 1));
      }
      if (a[n - 2][n - 1] == '0') {
        ans++;
        v.push_back(make_pair(n - 1, n));
      }
      cout << ans << endl;
      for (long long int i = 0; i < ans; i++) {
        cout << v[i].first << " " << v[i].second << endl;
      }
    } else if (a[0][1] == a[1][0] && (a[0][1] == '1')) {
      long long int ans = 0;
      vector<pair<long long int, long long int>> v;
      if (a[n - 1][n - 2] == '1') {
        ans++;
        v.push_back(make_pair(n, n - 1));
      }
      if (a[n - 2][n - 1] == '1') {
        ans++;
        v.push_back(make_pair(n - 1, n));
      }
      cout << ans << endl;
      for (long long int i = 0; i < ans; i++) {
        cout << v[i].first << " " << v[i].second << endl;
      }
    } else {
      vector<pair<long long int, long long int>> ones;
      vector<pair<long long int, long long int>> zeros;
      long long int one = 0, zero = 0;
      if (a[n - 1][n - 2] == '1') {
        one++;
        ones.push_back(make_pair(n, n - 1));
      }
      if (a[n - 2][n - 1] == '1') {
        one++;
        ones.push_back(make_pair(n - 1, n));
      } else if (a[n - 1][n - 2] == '0') {
        zero++;
        zeros.push_back(make_pair(n, n - 1));
      } else if (a[n - 2][n - 1] == '0') {
        zero++;
        zeros.push_back(make_pair(n - 1, n));
      }
      if (one == zero) {
        cout << 1 << endl;
        for (long long int i = 0; i < zeros.size(); i++) {
          cout << zeros[i].first << " " << zeros[i].second << endl;
        }
      } else {
        cout << 0 << endl;
      }
    }
  }
}
