#include <bits/stdc++.h>
using namespace std;
long long dx[4] = {1, -1, 0, 0};
long long dy[4] = {0, 0, 1, -1};
char a[201][201];
bool vis[201][201];
long long n;
bool zero, one;
bool valid(long long x, long long y, char val) {
  if (x < 0 || x >= n || y < 0 || y >= n) return 0;
  if (vis[x][y] == 1) return 0;
  if (a[x][y] != val) {
    if (a[x][y] == 'S' || a[x][y] == 'F')
      return 1;
    else
      return 0;
  }
  return 1;
}
void dfs(long long x, long long y, char val) {
  vis[x][y] = 1;
  if (x == n - 1 && y == n - 1) {
    if (val == '0')
      zero = 1;
    else
      one = 1;
    return;
  }
  for (long long i = 0; i < 4; i++) {
    long long nx = x + dx[i];
    long long ny = y + dy[i];
    if (valid(nx, ny, val)) dfs(nx, ny, val);
  }
}
void solve() {
  cin >> n;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) cin >> a[i][j];
  }
  zero = 0, one = 0;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) vis[i][j] = 0;
  }
  dfs(0, 0, '0');
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) vis[i][j] = 0;
  }
  dfs(0, 0, '1');
  vector<pair<long long, long long>> v;
  if (one == 1 && zero == 0) {
    if (a[n - 2][n - 1] == '1') v.push_back({n - 1, n});
    if (a[n - 1][n - 2] == '1') v.push_back({n, n - 1});
  } else if (zero == 1 && one == 0) {
    if (a[n - 2][n - 1] == '0') v.push_back({n - 1, n});
    if (a[n - 1][n - 2] == '0') v.push_back({n, n - 1});
  } else if (zero == 1 && one == 1) {
    if (a[0][1] == '0')
      v.push_back({1, 2});
    else
      v.push_back({2, 1});
    if (a[n - 2][n - 1] == '1')
      v.push_back({n - 1, n});
    else
      v.push_back({n, n - 1});
  }
  cout << v.size() << "\n";
  for (long long i = 0; i < v.size(); i++)
    cout << v[i].first << " " << v[i].second << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}
