#include <bits/stdc++.h>
using namespace std;
int MAX = 200;
int main() {
  int T;
  cin >> T;
  for (int zz = 0; zz < T; zz++) {
    int N;
    cin >> N;
    char grid[200][200] = {'S'};
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        char temp;
        cin >> temp;
        grid[i][j] = temp;
      }
    }
    if (N == 3) {
      if ((grid[0][1] == '1') && (grid[0][2] == '0') && (grid[1][0] == '1') &&
          (grid[1][1] == '0') && (grid[1][2] == '1') && (grid[2][0] == '0') &&
          (grid[2][1] == '1')) {
        cout << "2\n";
        cout << "1 2\n2 1\n";
        continue;
      }
    }
    vector<pair<int, int>> remove_these;
    stack<pair<int, int>> s;
    s.push(pair<int, int>(0, 0));
    pair<int, int> p;
    int zero_path_exist = 0;
    int x, y;
    while (!s.empty()) {
      p = s.top();
      x = p.first;
      y = p.second;
      s.pop();
      if ((x + 1) < N && (grid[x + 1][y] == '0'))
        s.push(pair<int, int>(x + 1, y));
      if ((y + 1) < N && (grid[x][y + 1] == '0'))
        s.push(pair<int, int>(x, y + 1));
      if ((x + 1) < N && (grid[x + 1][y] == 'F')) {
        zero_path_exist = 1;
        remove_these.push_back(pair<int, int>(x, y));
        break;
      }
      if ((y + 1) < N && (grid[x][y + 1] == 'F')) {
        zero_path_exist = 1;
        remove_these.push_back(pair<int, int>(x, y));
        break;
      }
    }
    int one_path_exist = 0;
    stack<pair<int, int>> s2;
    s2.push(pair<int, int>(0, 0));
    while (!s2.empty()) {
      p = s2.top();
      x = p.first;
      y = p.second;
      s2.pop();
      if ((x + 1) < N && (grid[x + 1][y] == '1'))
        s2.push(pair<int, int>(x + 1, y));
      if ((y + 1) < N && (grid[x][y + 1] == '1'))
        s2.push(pair<int, int>(x, y + 1));
      if ((x + 1) < N && (grid[x + 1][y] == 'F')) {
        one_path_exist = 1;
        remove_these.push_back(pair<int, int>(x, y));
        break;
      }
      if ((y + 1) < N && (grid[x][y + 1] == 'F')) {
        one_path_exist = 1;
        remove_these.push_back(pair<int, int>(x, y));
        break;
      }
    }
    if (zero_path_exist == 1 || one_path_exist == 1) {
      cout << zero_path_exist + one_path_exist << "\n";
      for (int i = 0; i < remove_these.size(); i++)
        cout << remove_these[i].first + 1 << " " << remove_these[i].second + 1
             << "\n";
    } else {
      cout << "0\n";
    }
  }
  return 0;
}
