

for _ in range(int(input())):
    n = int(input())
    m = []
    for i in range(n):
        m.append(list(input()))

    ans = 0
    l = []
    a = m[1][0]
    b = m[0][1]
    c = m[n-1][n-2]
    d = m[n-2][n-1]
    
    if(a != b):
        if(c == d):
            if(a == c):
                   l.append((1,0))
            else:
                   l.append((0,1))
        else:
           if(a != c):
               l.append((0,1))
               l.append((n-1,n-2))
           else:
               l.append((1,0))
               l.append((n-2,n-1))

           
    else:
        if(c == d):
            if(a == c):
                   l.append((1,0))
                   l.append((0,1))
           
        else:
           if(a != c):
               l.append((n-2,n-1))
           else:
               l.append((n-1,n-2))


    print(len(l))
    for i in l:
        print(i[0]+1,i[1]+1)
           
           
