#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    char arr[n][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) cin >> arr[i][j];
    }
    if (arr[0][1] == arr[1][0]) {
      int x, y;
      if (arr[n - 1][n - 2] == arr[1][0] && arr[n - 2][n - 1] == arr[1][0]) {
        cout << 2 << "\n";
        x = n - 1 + 1;
        y = n - 2 + 1;
        cout << x << " " << y << "\n";
        cout << y << " " << x << "\n";
      } else if (arr[n - 1][n - 2] == arr[1][0] &&
                 arr[n - 2][n - 1] != arr[1][0]) {
        cout << 1 << "\n";
        cout << n << " " << n - 1 << "\n";
      } else if (arr[n - 2][n - 1] == arr[1][0] &&
                 arr[n - 1][n - 2] != arr[1][0]) {
        cout << 1 << "\n";
        cout << n - 1 << " " << n << "\n";
      } else
        cout << 0 << "\n";
    }
  }
  return 0;
}
