import sys
if sys.subversion[0] == "PyPy":
    import io, atexit
    sys.stdout = io.BytesIO()
    atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))
    
    sys.stdin = io.BytesIO(sys.stdin.read())
    input = lambda: sys.stdin.readline().rstrip()

RS = raw_input
RI = lambda x=int: map(x,RS().split())
RN = lambda x=int: x(RS())
''' ...................................................................... '''

def solve(mat,a,b,f):
    out1 = []
    for x,y in a:
        if mat[x-1][y-1]!=f:
            out1.append([x,y])
    for x,y in b:
        if mat[x-1][y-1]==f:
            out1.append([x,y])
    return out1        

for _ in xrange(RN()):
    n = RN()
    mat = [RS() for i in xrange(n)]

    a = [[1,2],[2,1]]
    b = [[n,n-1],[n-1,n]]

    out = solve(mat,a,b,'0')
    if len(out)>2:
        out = solve(mat,a,b,'1')

    print len(out)
    for ii in out:
        print ii[0],ii[1]
