#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  int t;
  cin >> t;
  while (t--) {
    int n, count = 0, x1 = 0, y1 = 0, x2 = 0, y2 = 0;
    cin >> n;
    string grid[n];
    for (auto &i : grid) cin >> i;
    if (grid[0][1] == grid[n - 2][n - 1] || grid[1][0] == grid[n - 2][n - 1]) {
      count++;
      x1 = n - 1;
      y1 = n;
    }
    if (grid[0][1] == grid[n - 1][n - 2] || grid[1][0] == grid[n - 1][n - 2]) {
      count++;
      if (!x1)
        x1 = n;
      else
        x2 = n;
      if (!y1)
        y1 = n - 1;
      else
        y2 = n - 1;
    }
    if (!x1 && !y1)
      cout << count << '\n';
    else if (count == 1)
      cout << count << '\n' << x1 << " " << y1 << '\n';
    else
      cout << count << '\n'
           << x1 << " " << y1 << '\n'
           << x2 << " " << y2 << '\n';
  }
  return 0;
}
