#include <bits/stdc++.h>
using namespace std;
struct coordinate {
  int x, y;
};
char arr[201][201];
int n;
vector<coordinate> v;
int bfs(coordinate temp, int counts) {
  queue<coordinate> q;
  q.push(temp);
  int level[201][201];
  int val = arr[temp.x][temp.y];
  memset(level, 0, sizeof(level));
  int row[4] = {-1, 0, 1, 0};
  int col[4] = {0, -1, 0, 1};
  while (!q.empty()) {
    coordinate t = q.front();
    q.pop();
    int i = 0, times = 0;
    while (i < 4) {
      coordinate a = t;
      a.x += row[i];
      a.y += col[i];
      if (arr[a.x][a.y] == 'F') return 0;
      if (a.x >= 0 && a.y >= 0 && a.x < n && a.y < n && level[a.x][a.y] == 0 &&
          arr[a.x][a.y] != 'S' && arr[a.x][a.y] == val) {
        q.push(a);
        level[a.x][a.y] = 1;
        times++;
      }
      i++;
    }
    if (times > 1 && counts == 0) {
      v.push_back(t);
      counts++;
    }
  }
  return 1;
}
int main() {
  int test;
  cin >> test;
  while (test--) {
    cin >> n;
    int i = 0, j = 0;
    while (i < n) {
      j = 0;
      while (j < n) {
        cin >> arr[i][j];
        j++;
      }
      i++;
    }
    if (arr[0][1] == 0 && arr[1][0] == 0) {
      if (arr[n - 1][n - 2] == 1 && arr[n - 2][n - 1] == 1)
        cout << "0" << endl;
      else if (arr[n - 1][n - 2] == 1 && arr[n - 2][n - 1] == 0) {
        cout << "1" << endl;
        cout << n - 1 << " " << n << endl;
      } else if (arr[n - 1][n - 2] == 0 && arr[n - 2][n - 1] == 1) {
        cout << "1" << endl;
        cout << n << " " << n - 1 << endl;
      } else {
        cout << "2" << endl;
        cout << n - 1 << " " << n << endl;
        cout << n << " " << n - 1 << endl;
      }
    } else if (arr[0][1] == 0 && arr[1][0] == 1) {
      if (arr[n - 1][n - 2] == 1 && arr[n - 2][n - 1] == 1) {
        cout << "1" << endl;
        cout << "2 1" << endl;
      } else if (arr[n - 1][n - 2] == 1 && arr[n - 2][n - 1] == 0) {
        cout << "2" << endl;
        cout << "2 1" << endl;
        cout << n - 1 << " " << n << endl;
      } else if (arr[n - 1][n - 2] == 0 && arr[n - 2][n - 1] == 1) {
        cout << "2" << endl;
        cout << "2 1" << endl;
        cout << n << " " << n - 1 << endl;
      } else {
        cout << "1" << endl;
        cout << "2 1" << endl;
      }
    } else if (arr[0][1] == 1 && arr[1][0] == 0) {
      if (arr[n - 1][n - 2] == 1 && arr[n - 2][n - 1] == 1) {
        cout << "1" << endl;
        cout << "1 2" << endl;
      } else if (arr[n - 1][n - 2] == 1 && arr[n - 2][n - 1] == 0) {
        cout << "2" << endl;
        cout << "2 1" << endl;
        cout << n << " " << n - 1 << endl;
      } else if (arr[n - 1][n - 2] == 0 && arr[n - 2][n - 1] == 1) {
        cout << "2" << endl;
        cout << "2 1" << endl;
        cout << n - 1 << " " << n << endl;
      } else {
        cout << "1" << endl;
        cout << "1 2" << endl;
      }
    } else {
      if (arr[n - 1][n - 2] == 1 && arr[n - 2][n - 1] == 1) {
        cout << "2" << endl;
        cout << "1 2" << endl;
        cout << "2 1" << endl;
      } else if (arr[n - 1][n - 2] == 1 && arr[n - 2][n - 1] == 0) {
        cout << "1" << endl;
        cout << n << " " << n - 1 << endl;
      } else if (arr[n - 1][n - 2] == 0 && arr[n - 2][n - 1] == 1) {
        cout << "1" << endl;
        cout << n - 1 << " " << n << endl;
      } else {
        cout << "2" << endl;
        cout << "1 2" << endl;
        cout << "2 1" << endl;
      }
    }
  }
  return 0;
}
