for _ in range(int(input())):
    n = int(input())
    A = []
    for i in range(n):
        s = input()
        A.append(s)
    if int(A[n-1][n-2]) == 0 and int(A[n-2][n-1]) == 0:
        print(2)
        print(n-1,n)
        print(n,n-1)
    elif int(A[n-1][n-2]) == 0:
        print(1)
        print(n,n-1)
    elif int(A[n-2][n-1]) == 0:
        print(1)
        print(n-1,n)
    elif int(A[0][1]) == 1 and int(A[1][0]) == 1:
        print(2)
        print(1,2)
        print(2,1)
    elif int(A[0][1]) == 1:
        print(1)
        print(1,2)
    elif int(A[1][0]) == 1:
        print(1)
        print(2,1)
    else:
        print(0)