for i in range(int(input())):
    n=int(input())
    p=[]
    for i in range(n):
        x=input()
        p.append(x)

    if p[-1][-2]==p[-2][-1]:
        if p[-2][-2]==p[-1][-2]:
            print(1)
            print(n-1,n-1)
        elif p[-2][-2]!=p[-2][-1]:
            if p[-1][-2]==p[-1][-3]:
                print(1)
                print(n,n-2)
            elif p[-2][-1]==p[-3][-1]:
                print(1)
                print(n-2,n)
            elif p[-3][-1]==p[-1][-3]:
                print(0)
    elif p[-1][-2]!=p[-2][-1]:
        if p[-1][-2]==p[-2][-2]:
            print(1)
            print(n,n-1)
        elif p[-2][-1]==p[-2][-2]:
            print(1)
            print(n-1,n)
        