t=int(input())
for i in range(t):
    n=int(input())
    l=[]
    for i2 in range(n):
        l.append(list(input()))
    p1=l[0][1]
    p2=l[1][0]
    p3=l[n-1][n-1]
    p4=l[n-1][n-2]
    c=0
    l2=[]
    if (p1=='0' and p2=='0'):
        if(p3=='0'):
            l2.append(n-1)
            l2.append(n-1)
            c=c+1
        if(p4=='0'):
            l2.append(n-1)
            l2.append(n-2)
            c=c+1    
    elif (p1=='1' and p2=='1'):
        if(p3=='1'):
            l2.append(n-1)
            l2.append(n-1)
            c=c+1
        if(p4=='1'):
            l2.append(n-1)
            l2.append(n-2)
            c=c+1    
    print(c)
    for j in range(c):
        k1=l2.pop(0)
        k2=l2.pop(0)
        print("{} {}".format(k1,k2))        
            
        
        