for _ in range(int(input())):
    arr=[]
    n=int(input())
    for i in range(n):
        x=raw_input()
        y=[x[i] for i in range(n)]
        arr.append(y)

    def solve(arr,n):
        if arr[0][1]==arr[1][0]:
            if arr[n-2][n-1]==arr[0][1] and arr[n-1][n-2]==arr[0][1]:
                print 2
                print n-1,n
                print n,n-1

            elif arr[n-2][n-1]==arr[n-1][n-2] and arr[n-2][n-1]!=arr[0][1]:
                print 0

            else:
                if arr[n-1][n-2]!=arr[0][1] and arr[n-2][n-1]==arr[0][1]:
                    print 1
                    print n-1,n

                elif arr[n-1][n-2]==arr[0][1] and arr[n-2][n-1]!=arr[0][1]:
                    print 1
                    print n,n-1
        else:
            if arr[n-1][n-2]==arr[n-2][n-1]:

                if arr[0][1]==arr[n-1][n-2]:
                    print 1
                    print 1,2
                elif arr[1][0]==arr[n-1][n-2]:
                    print 1
                    print 2,1

            else:
                if arr[0][1]==arr[n-1][n-2] and arr[1][0]==arr[n-2][n-1]:
                    print 2
                    print 1,2
                    print n-1,n

                elif arr[0][1]==arr[n-2][n-1] and arr[1][0]==arr[n-1][n-2]:
                    print 2
                    print 2,1
                    print n-1,n


    solve(arr,n)