#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int tc;
  cin >> tc;
  while (tc--) {
    int n;
    cin >> n;
    vector<vector<char>> arr(n, vector<char>(n));
    for (auto& y : arr)
      for (auto& x : y) cin >> x;
    vector<pair<int, int>> res;
    if (arr[0][1] == arr[1][0]) {
      char k = arr[0][1];
      if (k == '1')
        k = '0';
      else if (k == '0')
        k = '1';
      if (k != arr[n - 1][n - 2]) {
        res.push_back(make_pair(n, n - 1));
      }
      if (k != arr[n - 2][n - 1]) {
        res.push_back(make_pair(n - 1, n));
      }
    } else if (arr[n - 1][n - 2] == arr[n - 2][n - 1]) {
      char k = arr[n - 1][n - 2];
      if (k == '1')
        k = '0';
      else if (k == '0')
        k = '1';
      if (k != arr[0][1]) {
        res.push_back(make_pair(1, 2));
      }
      if (k != arr[1][0]) {
        res.push_back(make_pair(1, 2));
      }
    } else {
      int k = arr[0][1];
      res.push_back(make_pair(2, 1));
      if (k == '1')
        k = '0';
      else if (k == '0')
        k = '1';
      if (k != arr[n - 1][n - 2]) {
        res.push_back(make_pair(n, n - 1));
      }
      if (k != arr[n - 2][n - 1]) {
        res.push_back(make_pair(n - 1, n));
      }
    }
    cout << res.size() << "\n";
    for (auto u : res) cout << u.first << " " << u.second << "\n";
  }
}
