t = int(input())
for _ in range(t):
    ans = []
    final = []
    n = int(input())
    for i in range(n):
        s = input()
        lol = list(s)
        ans.append(s)
    a = ans[0][1]
    b = ans[1][0]
    
    x = ans[n-2][n-1]
    y = ans[n-1][n-2]
    
    #print(a,b,x,y)
    if(a == b):
        if(x==a):
            final.append([n-1,n])
        if(y==a):
            final.append([n,n-1])
    elif(a!=b and x!=y):
        if(a==0):
            final.append([1,2])
        else:
            final.append([2,1])
        if(x==0):
            final.append([n-1,n])
        else:
            final.append([n,n-1])    
            
    else:
        if(x == y):
            if(a==x):
                final.append([1,2])
            else:
                final.append([2,1])
        
            
    print(len(final))
    for i in final:
        print(*i,end ='\n')