#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<string> graph(n);
    for (auto &i : graph) cin >> i;
    if ((graph[0][1] == graph[n - 2][n - 1]) and
        (graph[1][0] == graph[n - 1][n - 2]) and (graph[0][1] != graph[1][0])) {
      cout << 2 << endl;
      cout << "1 2" << endl << n - 1 << " " << n << endl;
      continue;
    }
    if ((graph[0][1] == graph[n - 1][n - 2]) and
        (graph[1][0] == graph[n - 2][n - 1]) and (graph[0][1] != graph[1][0])) {
      cout << 2 << endl;
      cout << "1 2" << endl << n << " " << n - 1 << endl;
      continue;
    }
    if (graph[1][0] == graph[n - 1][n - 2]) {
      cout << 1 << endl;
      cout << "2 1" << endl;
      continue;
    }
    if (graph[1][0] == graph[n - 2][n - 1]) {
      cout << 1 << endl;
      cout << "2 1" << endl;
      continue;
    }
    if (graph[0][1] == graph[n - 1][n - 2]) {
      cout << 1 << endl;
      cout << "1 2" << endl;
      continue;
    }
    if (graph[0][1] == graph[n - 2][n - 1]) {
      cout << 1 << endl;
      cout << "1 2" << endl;
      continue;
    }
    cout << 0 << endl;
  }
  return 0;
}
