#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
int max(int a, int b) {
  if (a > b)
    return a;
  else
    return b;
}
int min(int a, int b) {
  if (a < b)
    return a;
  else
    return b;
}
bool isPrime(int N) {
  for (int i = 2; i * i <= N; ++i) {
    if (N % i == 0) return false;
  }
  return true;
}
void solve() {
  long long int n;
  cin >> n;
  char arr[n + 1][n + 1];
  for (int(i) = (1); (i) <= (n); (i)++)
    for (int(j) = (1); (j) <= (n); (j)++) cin >> arr[i][j];
  if (arr[1][2] == arr[2][1] and arr[n - 1][n] == arr[n][n - 1] and
      arr[n][n - 1] != arr[1][2]) {
    cout << 0 << "\n";
    return;
  }
  if (arr[1][2] == arr[2][1] and arr[n - 1][n] == arr[n][n - 1] and
      arr[n][n - 1] == arr[1][2]) {
    cout << 2 << "\n";
    cout << 1 << " " << 2 << "\n";
    cout << 2 << " " << 1 << "\n";
    return;
  }
  if (arr[1][2] != arr[2][1] and arr[n - 1][n] == arr[n][n - 1]) {
    if (arr[n - 1][n] == arr[1][2]) {
      cout << 1 << "\n";
      cout << 1 << " " << 2 << "\n";
    } else {
      cout << 1 << "\n";
      cout << 2 << " " << 1 << "\n";
    }
    return;
  }
  if (arr[1][2] == arr[2][1] and arr[n - 1][n] != arr[n][n - 1]) {
    if (arr[1][2] == arr[n - 1][n]) {
      cout << 1 << "\n";
      cout << n - 1 << " " << n << "\n";
    } else {
      cout << 1 << "\n";
      cout << n << " " << n - 1 << "\n";
    }
    return;
  }
  if (arr[1][2] != arr[2][1] and arr[n - 1][n] != arr[n][n - 1]) {
    cout << 2 << "\n";
    if (arr[1][2] == 1)
      cout << 1 << " " << 2 << "\n";
    else
      cout << 2 << " " << 1 << "\n";
    if (arr[n - 1][n] == 0)
      cout << n - 1 << " " << n << "\n";
    else
      cout << n << " " << n - 1 << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
