def matrix(arr,n):
    x=int(arr[0][1])+int(arr[1][0])
    y=int(arr[n-1][n-2])+int(arr[n-2][n-1])
    if x==2:
        if y==0:
            print(0)
            return
        if y==1:
            print(1)
            if arr[n-2][n-1]=='1':
                print(n-1,n)
                return
            else:
                print(n,n-1)
                return
        if y==2:
            print(2)
            print(1,2)
            print(2,1)
            return
    if x==1:
        if y==0:
            print(1)
            if arr[1][2]=='0':
                print(1,2)
                return
            else:
                print(2,1)
                return 
        if y==2:
            print(1)
            if arr[1][2]=='0':
                print(2,1)
                return
            else:
                print(1,2)
                return
        if y==1:
            print(2)
            if arr[1][2]=='1':
                print(1,2)
            else:
                print(2,1)
            if arr[n-1][n-2]=='0':
                print(n,n-1)
            else:
                print(n-1,n)
    if x==0:
        if y==1:
            print(1)
            if arr[n-2][n-1]=='1':
                print(n,n-1)
                return
            else:
                print(n-1,n)
                return
        if y==2:
            print(0)
            return
        if y==0:
            print(2)
            print(1,2)
            print(2,1)
            return
if __name__ == "__main__":
    for i in range(int(input())):
        n=int(input())
        arr=[]
        for i in range(n):
            arr.append(list(map(str,input())))
        matrix(arr,n)
        