#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t-- > 0) {
    int n;
    cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; i++) {
      cin >> s[i];
    }
    vector<pair<int, int>> res;
    if (s[0][1] == s[n - 1][n - 2]) {
      s[n - 1][n - 2] = (s[0][1] == '1') ? '0' : '1';
      res.push_back(pair<int, int>(n, n - 1));
    }
    if (s[0][1] == s[n - 2][n - 1]) {
      s[n - 2][n - 1] = (s[0][1] == '1') ? '0' : '1';
      res.push_back(pair<int, int>(n - 1, n));
    }
    if (s[0][1] != s[1][0]) {
      s[1][0] = s[0][1];
      res.push_back(pair<int, int>(2, 1));
    }
    cout << res.size() << endl;
    for (int i = 0; i < res.size(); i++) {
      cout << res[i].first << " " << res[i].second << endl;
    }
  }
  return 0;
}
