#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<string> grid(n);
    vector<pair<int, int>> ans;
    for (int i = 0; i < n; i++) cin >> grid[i];
    int a = grid[0][1], b = grid[1][0], c = grid[n - 1][n - 2],
        d = grid[n - 2][n - 1];
    int C = 0;
    if (a == b) {
      if (a == '1') {
        if (c != '0') {
          C++;
          ans.push_back({n - 1, n - 2});
        }
        if (d != '0') {
          C++;
          ans.push_back({n - 2, n - 1});
        }
      } else {
        if (c != '1') {
          C++;
          ans.push_back({n - 1, n - 2});
        }
        if (d != '1') {
          C++;
          ans.push_back({n - 2, n - 1});
        }
      }
    } else if (c == d) {
      if (c == '1') {
        if (a != '0') {
          C++;
          ans.push_back({0, 1});
        }
        if (b != '0') {
          C++;
          ans.push_back({1, 0});
        }
      } else {
        if (a != '1') {
          C++;
          ans.push_back({0, 1});
        }
        if (b != '1') {
          C++;
          ans.push_back({1, 0});
        }
      }
    } else {
      if (a == c) {
        C += 2;
        ans.push_back({0, 1});
        ans.push_back({n - 2, n - 1});
      } else if (a == d) {
        C += 2;
        ans.push_back({0, 1});
        ans.push_back({n - 1, n - 2});
      }
    }
    cout << C << endl;
    for (int i = 0; i < C; i++)
      cout << ans[i].first << " " << ans[i].second << endl;
  }
  return 0;
}
