import sys
input = sys.stdin.readline

def solve():
    n=int(input())
    M=[list(input().strip()) for _ in range(n)]
    def check(f):
        ans= []
        if M[0][1]==M[1][0]==f:
            if M[n-1][n-2]==f:
                ans.append([n,n-1])
            if M[n-2][n-1]==f:
                ans.append([n-1,n])
        return ans

    def pr(ans):
        print(len(ans))
        for i in ans:
            print(*i)
    
    ans = check('1')
    if ans !=[]:
        pr(ans)
        return

    ans = check('0')
    if ans !=[]:
        pr(ans)
        return
    
    print(0)
    
            

if __name__=="__main__":
    for _ in range(int(input())):
        solve()



