#include <bits/stdc++.h>
using namespace std;
template <class T, typename A = allocator<T>>
class Vector : public vector<T, A> {
 public:
  using vector<T, A>::vector;
  using typename vector<T, A>::size_type;
  using typename vector<T, A>::value_type;
  using typename vector<T, A>::allocator_type;
  Vector& operator()(size_type dummy_n, const value_type& val = value_type(),
                     const allocator_type& alloc = allocator_type()) {
    return *this;
  }
};
template <>
class Vector<string> : public vector<string> {
 public:
  using vector<string>::vector;
  Vector& operator()(size_type dummy_n) { return *this; }
};
typedef Vector<bool> vb;
template <typename Int = int>
inline Int read() {
  int c{getchar()};
  if (c == '-') {
    Int init{getchar() & 15};
    while ((c = getchar()) & 16) init = (init << 3) + (init << 1) + (c & 15);
    return ++(init = ~init);
  } else {
    Int init{c & 15};
    while ((c = getchar()) & 16) init = (init << 3) + (init << 1) + (c & 15);
    return init;
  }
}
inline void read(int& a) {
  a = getchar() & 15;
  if (a == 13) {
    a = getchar() & 15;
    for (int c; (c = getchar()) & 16; a = (a << 3) + (a << 1) + (c & 15))
      ;
    ++(a = ~a);
  } else
    for (int c; (c = getchar()) & 16; a = (a << 3) + (a << 1) + (c & 15))
      ;
}
inline void read(unsigned int& a) {
  a = getchar() & 15;
  for (int c; (c = getchar()) & 16; a = (a << 3) + (a << 1) + (c & 15))
    ;
}
inline void read(char& a) { scanf("%c%*c", &a); }
inline void read(string& a) {
  static char BUF[1234560];
  scanf("%s%*c", BUF);
  a = move(string(BUF));
}
inline void read(long long& a) { a = read<long long>(); }
inline void read(double& a) { scanf("%lf%*c", &a); }
template <class T>
inline void read(pair<T, T>& a) {
  read(a.first);
  read(a.second);
}
template <template <typename T, typename A = allocator<T>> class C, class T>
inline void read(C<T>& a) {
  for (auto i = a.begin(); i != a.end(); ++i) read(*i);
}
template <typename T, typename U, typename... ARGS>
inline void read(T& t, U& unsigned int, ARGS&... args) {
  read(t);
  read(unsigned int, args...);
}
template <typename Int>
inline void write(Int x) {
  static char BUF[64] = {};
  char* pnt{BUF + 64};
  if (x < 0) {
    putchar('-');
    ++(x = ~x);
  }
  do *--pnt = x % 10 | 48;
  while (x /= 10);
  printf("%s", pnt);
}
inline void write(unsigned int a) {
  static char BUF[16] = {};
  char* pnt{BUF + 16};
  do *--pnt = a % 10 | 48;
  while (a /= 10);
  printf("%s", pnt);
}
inline void write(const char& a) { printf("%c", a); }
inline void write(const char* a) { printf("%s", a); }
inline void write(const string& a) { printf("%s", a.c_str()); }
inline void write(const double& a) { printf("%lf", a); }
template <class T>
inline void write(const pair<T, T>& a) {
  write(a.first);
  write(' ');
  write(a.second);
}
template <template <typename T, typename A = allocator<T>> class C, class T>
inline void write(const C<T>& a) {
  if (a.size()) {
    auto i = a.begin();
    write(*i++);
    for (; i != a.end(); ++i) {
      write(' ');
      write(*i);
    }
  }
}
template <typename T, typename U, typename... ARGS>
inline void write(const T& t, const U& unsigned int, const ARGS&... args) {
  write(t);
  write(' ');
  write(unsigned int, args...);
}
template <template <typename T, typename A = allocator<T>> class C, class T>
inline void sort(C<T>& a) {
  sort(a.begin(), a.end());
}
inline void sort(string& a) { sort(a.begin(), a.end()); }
template <template <typename T, typename A = allocator<T>> class C, class T>
inline void rsort(C<T>& a) {
  sort(a.rbegin(), a.rend());
}
inline void rsort(string& a) { sort(a.rbegin(), a.rend()); }
template <
    template <class T, class Compare = less<T>, class Alloc = allocator<T>>
    class C,
    class T>
inline bool in(const C<T>& c, const T& el) {
  return c.find(el) != c.end();
};
template <template <class Key, class T, class Compare = less<Key>,
                    class Alloc = allocator<pair<const Key, T>>>
          class C,
          class Key, class T>
inline bool in(const C<Key, T>& c, const Key& el) {
  return c.find(el) != c.end();
};
template <template <typename T, typename A = allocator<T>> class C, class T>
inline bool in(const C<T>& c, const T& el) {
  return find(c.begin(), c.end(), el) != c.end();
};
template <
    template <class T, class Compare = less<T>, class Alloc = allocator<T>>
    class C,
    class T>
inline bool out(const C<T>& c, const T& el) {
  return c.find(el) == c.end();
};
template <template <class Key, class T, class Compare = less<Key>,
                    class Alloc = allocator<pair<const Key, T>>>
          class C,
          class Key, class T>
inline bool out(const C<Key, T>& c, const Key& el) {
  return c.find(el) == c.end();
};
template <template <typename T, typename A = allocator<T>> class C, class T>
inline bool out(const C<T>& c, const T& el) {
  return find(c.begin(), c.end(), el) == c.end();
}
int main() {
  unsigned int t;
  read(t);
  for (decltype(t) _VARIABLE{(t) + 1}; --_VARIABLE;) {
    unsigned int n;
    read(n);
    Vector<string> s(n);
    read(s(n));
    char& a = s[0][1];
    char& b = s[1][0];
    char& c = s[n - 2][n - 1];
    char& d = s[n - 1][n - 2];
    for (unsigned int i{}; i < 1 << 4; ++i) {
      char A = bool(i & 1) + '0';
      char B = bool(i & 2) + '0';
      char C = bool(i & 4) + '0';
      char D = bool(i & 8) + '0';
      if (A == B && C == D && A != C)
        if (unsigned int dist =
                abs(a - A) + abs(b - B) + abs(c - C) + abs(d - D);
            dist <= 2) {
          write(dist), write('\n');
          if (a != A) write(0 + 1, 1 + 1), write('\n');
          if (b != B) write(1 + 1, 0 + 1), write('\n');
          if (c != C) write(n - 2 + 1, n - 1 + 1), write('\n');
          if (d != D) write(n - 1 + 1, n - 2 + 1), write('\n');
        }
    }
  }
}
