for t in range(int(input())):
    n=int(input())
    arr=[]
    for i in range(n):
        row=list(input())
        arr.append(row)
    d1=[arr[1][0],arr[0][1]]
    d2=[arr[n-1][n-2],arr[n-2][n-1]]
    if d1==d2:
        print(2)
        print("1 2")
        print("2 1")
    elif (d1.count("1")==0 or d1.count("0")==0) and (d2.count("1")==0 or d2.count("0")==0):
        print(0)
    else:
        if d1.count("1")==0:
            count=1
            if d2[0]=="0":
                print(count)
                print(n,n-1)
            else:
                print(count)
                print(n-1,n)
        elif d1.count("0")==0:
            count=1
            if d2[0]=="1":
                print(count)
                print(n,n-1)
            else:
                print(count)
                print(n-1,n)
        elif d2.count("0")==0:
            count=1
            if d1[0]=="1":
                print(count)
                print(2, 1)
            else:
                print(count)
                print(2, 1)
        elif d2.count("1")==0:
            count=1
            if d1[0]=="0":
                print(count)
                print(2, 1)
            else:
                print(count)
                print(2, 1)