from __future__ import division
from sys import stdin, stdout
# from fractions import gcd
# from math import *
# from operator import mul
# from functools import reduce
# from copy import copy
from collections import deque, defaultdict, Counter

rstr = lambda: stdin.readline().strip()
rstrs = lambda: [str(x) for x in stdin.readline().split()]
rint = lambda: int(stdin.readline())
rints = lambda: [int(x) for x in stdin.readline().split()]
rstr_2d = lambda n: [rstr() for _ in range(n)]
rint_2d = lambda n: [rint() for _ in range(n)]
rints_2d = lambda n: [rints() for _ in range(n)]
pr = lambda args, sep: stdout.write(sep.join(map(str, args)) + '\n')
out = []
form = '{:0>5b}'

for _ in range(int(input())):
    n = rint()
    grid, chg = rstr_2d(n), [(n, n - 2), (n - 1, n - 1), (n - 2, n), (n, n - 1), (n - 1, n)]

    for i in range(1 << 5):
        num, dis = form.format(i), []

        for j, (x, y) in enumerate(chg):
            if grid[x - 1][y - 1] != num[j]:
                dis.append('%d %d' % (x, y))

        cond = (len(dis) < 3)
        for j in range(2):
            cond += ((num[j] != num[j + 3]) and (num[j + 1] != num[j + 3]))

        if cond == 3:
            out.append('%d\n%s' % (len(dis), '\n'.join(dis)))
            break

pr(out, '\n')
