t=int(input())

for _ in range(t):
    n=int(input())
    f=[]
    for i in range(n):
        f.append(str(input()))
    a=f[1][0]
    b=f[0][1]
    c=f[-1][-2]
    d=f[-2][-1]
    
    if a==b and c==d and a!=c:
        print(0)
    elif a==b and c==d and a==c:
        print(2)
        print(1,2)
        print(2,1)
    elif a==b:
        print(1)
        if d==a:
            print(n-1,n)
        else:
            print(n,n-1)
    else:
        if d==c:
            print(1)
            if d==a:
                print(2,1)
            else:
                print(1,2)
        else:
            print(2)
            if a==c:
                print(1,2)
                print(n,n-1)
            else:
                print(2,1)
                print(n-1,n)
    