import sys,functools,collections,bisect,math,heapq
input = sys.stdin.readline
#print = sys.stdout.write 


for _ in range(int(input())):
    n = int(input())
    mat = []
    for i in range(n):
        mat.append(input().strip())
    a1,a2 = mat[0][1],mat[1][0]
    b1,b2 = mat[-1][-2],mat[-2][-1]


    if a1 == a2:
        if b1 == b2:
            if a1 != b1:
                print(0)
                continue
            else:
                print(2)
                print(1,2)
                print(2,1)
                continue
        elif b1 == a1:
            print(1)
            print(n,n-1)
            continue
        else:
            print(1)
            print(n-1,n)
            continue
    else:
        if b1 == b2:
            if b1 != a1:
                print(1)
                print(1,2)
                continue
            else:
                print(1)
                print(2,1)
                continue
        elif b1 == a1:
            print(2)
            print(n,n-1)
            print(1,2)
            continue
        else:
            print(2)
            print(n,n-1)
            print(2,1)
            continue  