t=int(input())
for _ in range(t):
    n=int(input())
    mat=[input() for _ in range(n)]
    if(mat[1][0]==mat[0][1]):
        if(mat[n-2][n-1]==mat[n-1][n-2] and mat[n-2][n-1]!=mat[0][1] ):
            print(0)
        elif(mat[n-2][n-1]==mat[n-1][n-2] and mat[n-2][n-1]==mat[0][1] ):
            print(2)
            print(n-2,n-1)
            print(n-1,n-2)
        elif(mat[n-2][n-1]!=mat[n-1][n-2]):
            print(1)
            if(mat[n-2][n-1]==mat[1][0] or mat[n-2][n-1]==mat[0][1]):
                print(n-2,n-1)
            else:
                print(n-1,n-2)

    else:
        if(mat[n-2][n-1]==mat[n-1][n-2]):
            print(1)
            if(mat[n-2][n-1]==mat[1][0] or mat[n-2][n-1]==mat[0][1]):
                print(n-2,n-1)
            else:
                print(n-1,n-2)
        else:
            print(2)
            mat[n-2][n-1]=mat[n-1][n-2]
            if(mat[n-2][n-1]==1):
                if(mat[0][1]==1):
                    mat[0][1]=0
                    print(n-2,n-1)
                    print(0,1)
                else:
                    mat[1][0]=0
                    print(n-2,n-1)
                    print(1,0)
            else:
                if(mat[0][1]==0):
                    mat[0][1]=1
                    print(n-2,n-1)
                    print(0,1)
                else:
                    mat[1][0]=1
                    print(n-2,n-1)
                    print(1,0)



            
