#include <bits/stdc++.h>
using namespace std;
const int N = 250;
int main() {
  int t;
  cin >> t;
  while (t--) {
    char a[N][N];
    vector<pair<int, int> > q;
    int n;
    cin >> n;
    int sum = 0;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++) cin >> a[i][j];
    if (a[2][1] == a[1][2]) {
      if (a[n - 1][n] == a[2][1]) {
        sum++;
        q.push_back({n - 1, n});
      }
      if (a[n][n - 1] == a[2][1]) {
        sum++;
        q.push_back({n, n - 1});
      }
      printf("%d\n", sum);
      for (auto i : q) printf("%d %d\n", i.first, i.second);
    } else if (a[n][n - 1] == a[n - 1][n]) {
      if (a[2][1] == a[n][n - 1]) {
        sum++;
        q.push_back({2, 1});
      }
      if (a[1][2] == a[n][n - 1]) {
        sum++;
        q.push_back({1, 2});
      }
      printf("%d\n", sum);
      for (auto i : q) printf("%d %d\n", i.first, i.second);
    } else {
      if (a[n][n - 1] == a[1][2]) {
        sum++;
        q.push_back({n, n - 1});
      }
      if (a[n - 1][n] == a[1][2]) {
        sum++;
        q.push_back({n - 1, n});
      }
      printf("%d\n", sum);
      for (auto i : q) printf("%d %d\n", i.first, i.second);
      printf("2 1\n");
    }
  }
}
