#include <bits/stdc++.h>
using namespace std;
char map[205][205];
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++) cin >> map[i][j];
    if ((map[1][2] == '0' && map[2][1] == '0')) {
      int cnt = 0, a = 0, b = 0;
      if (map[n][n - 1] == '0') cnt++, a = 1;
      if (map[n - 1][n] == '0') cnt++, b = 1;
      cout << cnt << endl;
      if (a == 1) cout << n << " " << n - 1 << endl;
      if (b == 1) cout << n - 1 << " " << n << endl;
    } else if (map[1][2] == '1' && map[2][1] == '1') {
      int cnt = 0, a = 0, b = 0;
      if (map[n][n - 1] == '1') cnt++, a = 1;
      if (map[n - 1][n] == '1') cnt++, b = 1;
      cout << cnt << endl;
      if (a == 1) cout << n << " " << n - 1 << endl;
      if (b == 1) cout << n - 1 << " " << n << endl;
    } else if ((map[n][n - 1] == '0' && map[n - 1][n] == '0')) {
      int cnt = 0, a = 0, b = 0;
      if (map[1][2] == '0') cnt++, a = 1;
      if (map[2][1] == '0') cnt++, b = 1;
      cout << cnt << endl;
      if (a == 1) cout << 1 << " " << 2 << endl;
      if (b == 1) cout << 2 << " " << 1 << endl;
    } else if (map[n][n - 1] == '1' && map[n - 1][n] == '1') {
      int cnt = 0, a = 0, b = 0;
      if (map[1][2] == '1') cnt++, a = 1;
      if (map[2][1] == '1') cnt++, b = 1;
      cout << cnt << endl;
      if (a == 1) cout << 1 << " " << 2 << endl;
      if (b == 1) cout << 2 << " " << 1 << endl;
    } else {
      int cnt = 0, a = 0, b = 0, c = 0, d = 0;
      if (map[1][2] == '0') cnt++, a = 1;
      if (map[2][1] == '0') cnt++, b = 1;
      if (map[n][n - 1] == '0') cnt++, c = 1;
      if (map[n - 1][n] == '0') cnt++, d = 1;
      cout << cnt << endl;
      if (a == 1) cout << 1 << " " << 2 << endl;
      if (b == 1) cout << 2 << " " << 1 << endl;
      if (c == 1) cout << n << " " << n - 1 << endl;
      if (d == 1) cout << n - 1 << " " << n << endl;
    }
  }
  return 0;
}
