def f(n,mat):
    a,b = mat[0][1], mat[1][0]
    c,d = mat[-1][-2], mat[-2][-1]

    if a == b:
        if c == d:
            if c != a:
                print 0
                return 
            print 2
            print 1,2
            print 2,1
        else:
            if c == a:
                print 1
                print n,n-1
            else:
                print 1
                print n-1,n
        return
    elif a != b:
        if c == d:
            if a == c:
                print 1
                print 1,2
            elif b == c:
                print 1
                print 2,1
            return 
        else:
            if a == c:
                print 2 
                print 1,2
                print n-1,n
                return 
            elif b == c:
                print 2 
                print 1,2
                print n,n-1
                return 




for u in range(int(raw_input())):
    n = int(raw_input())
    mat = [list(raw_input()) for _ in range(n)]
    f(n,mat)