def process(n):
    mp = [raw_input() for _ in xrange(n)]
    if mp[1][0] == mp[0][1]:
        if mp[n - 2][n - 1] == mp[n - 1][n - 2]:
            if mp[1][0] != mp[n - 2][n - 1]:
                print 0
                return
            else:
                print 2
                print 1, 2
                print 2, 1
                return
        else:
            print 1
            if mp[1][0] == mp[n - 2][n - 1]:
                print n - 1, n
            else:
                print n, n - 1
            return
    elif mp[n - 2][n - 1] == mp[n - 1][n - 2]:
        print 1
        if mp[1][0] == mp[n - 2][n - 1]:
            print 2, 1
        else:
            print 1, 2
        return
    else:
        print 2
        if mp[1][0] == '1':
            print 2, 1
        else:
            print 1, 2
        if mp[n - 2][n - 1] == '0':
            print n - 1, n
        else:
            print n, n - 1
        
        
def main():
    t = input()
    for _ in xrange(t):
        n = input()
        process(n)

if __name__ == '__main__':
    main()