from sys import stdin
for _ in range(int(stdin.readline())):
    n = int(stdin.readline())
    ls =[]
    for  i in range(n):
        ls.append(list(input().strip()))

    poss1 = ls[0][1]
    poss2 =ls[1][0]
    f=1
    for i in range(n):
        if len(set(ls[i])) == 1 and poss1==poss2 and poss1 not in set(ls[i]):
            print(0)
            f=0
            break
    inv =0
    if f==1:
        if poss2 == poss1  :
            if ls[n-1][n-2] ==ls[n-2][n-1] :
                inv = 2
                print(inv)
                print(f'{n} {n-1}', f'{n-1} {n}',sep='\n' )
            else:
                print(1)
                if ls[n-1][n-2] != poss1:
                    print( n-1, n)
                else:print(n , n-1)
        else:
            print(2)
            print(f'{n} {n- 1}' ,f'{n-1} {n}', sep='\n')
