#include <bits/stdc++.h>
using namespace std;
struct node {
  int x, y;
} point[2];
int map[205][205];
char tmp[205];
void dfs(int x, int y, int n, int num) {
  if (x == n && y == n) return;
  int way = 0;
  if (x + 1 <= n && map[x + 1][y] == map[x][y]) way++;
  if (y + 1 <= n && map[x][y + 1] == map[x][y]) way++;
  if (way == 0)
    return;
  else if (way == 1) {
    if (x + 1 <= n && map[x + 1][y] == map[x][y]) {
      point[num].x = x + 1;
      point[num].y = y;
    }
    if (y + 1 <= n && map[x][y + 1] == map[x][y]) {
      point[num].x = x;
      point[num].y = y + 1;
    }
    return;
  }
  dfs(x + 1, y, n, num);
  dfs(x, y + 1, n, num);
  return;
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    memset(point, 0, sizeof(point));
    memset(map, 0, sizeof(map));
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
      scanf("%s", tmp);
      for (int j = 0; j < n; j++) {
        if (tmp[i] == 'S' || tmp[i] == 'F') {
          map[i][j] = -1;
          continue;
        }
        map[i][j + 1] = tmp[j] - '0';
      }
    }
    dfs(1, 2, n, 0);
    dfs(2, 1, n, 1);
    int num = 0;
    if (point[0].x != 0) num++;
    if (point[1].x != 0) num++;
    if (point[0].x == point[1].x && point[0].y == point[1].y && num == 2)
      num--, point[1].x = 0;
    printf("%d\n", num);
    for (int i = 0; i <= 1; i++)
      if (point[i].x != 0) printf("%d %d\n", point[i].x, point[i].y);
  }
  return 0;
}
