#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    cin >> n;
    string s[201];
    for (int i = 0; i < n; i++) {
      cin >> s[i];
    }
    set<pair<int, int> > ops;
    if (s[0][1] != s[1][0]) {
      if (s[0][1] == '0') ops.insert(make_pair(2, 1));
      if (s[1][0] == '0') ops.insert(make_pair(1, 2));
      s[0][1] = s[1][0] = '0';
    }
    if (s[n - 1][n - 2] != s[n - 2][n - 1]) {
      if (s[n - 1][n - 2] == '1') ops.insert(make_pair(n - 1, n));
      if (s[n - 2][n - 1] == '1') ops.insert(make_pair(n, n - 1));
      s[n - 1][n - 2] = s[n - 2][n - 1] = '1';
    }
    if (s[0][1] == s[n - 1][n - 2]) {
      if (s[0][1] == '1' && ops.empty()) {
        ops.insert(make_pair(1, 2));
        ops.insert(make_pair(2, 1));
        s[0][1] = s[1][0] = '0';
      }
      if (s[n - 1][n - 2] == '0' && ops.empty()) {
        ops.insert(make_pair(n - 1, n));
        ops.insert(make_pair(n, n - 1));
        s[0][1] = s[1][0] = '0';
      }
    }
    cout << ops.size() << "\n";
    for (auto x : ops) {
      cout << x.first << " " << x.second << "\n";
    }
  }
}
