#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string grid[n];
    for (int i = 0; i < n; i++) cin >> grid[i];
    int a = grid[0][1], b = grid[1][0], x = grid[n - 2][n - 1],
        y = grid[n - 1][n - 2];
    if (a == b) {
      int ans = (int)(a == x) + (int)(a == y);
      cout << ans << endl;
      if (a == x) cout << n - 1 << ' ' << n << endl;
      if (a == y) cout << n << ' ' << n - 1 << endl;
    } else {
      if (x == y) {
        cout << 1 << endl;
        if (a == x)
          cout << 0 << ' ' << 1 << endl;
        else
          cout << 1 << ' ' << 0 << endl;
      } else {
        cout << 2 << endl;
        cout << "0 1\n";
        if (x == b) cout << n - 1 << ' ' << n << endl;
        if (y == b) cout << n << ' ' << n - 1 << endl;
      }
    }
  }
  return 0;
}
