for _ in range(int(input())):
    n=int(input())
    ar=[]
    for i in range(n):    
        ar.append(list(input()))
    ar2=[]
    if ar[0][1]==ar[n-1][n-2]:
        ar2.append([1,2])
    if ar[1][0]==ar[n-2][n-1]:
        ar2.append([2,1])   
    if len(ar2)==0:
        print(0)
    else:
        print(len(ar2))
        for i in ar2:
            print(*i)