t = input()
for i in xrange(t):
    n = input()
    grid = []
    for j in xrange(n):
        a = raw_input()
        grid.append(a)
    a, b = grid[0][1], grid[1][0]
    c, d = grid[n-1][n-2], grid[n-2][n-1]
    if a == b:
        if c == d:
            if b != c:
                print 0
            if b == c:
                print 2
                print n, n-1
                print n-1, n
        if c != d:
            if c == b:
                print 1
                print n, n-1
            if d == b:
                print 1
                print n-1, n
    if a != b:
        if c == d:
            if b == c:
                print 1
                print 2, 1
            if a == c:
                print 1
                print 1, 2
        if c != d:
            if c == b:
                print 1
                print n, n-1
            if d == b:
                print 1
                print n-1, n
