def main():
    for i in range(int(input())):
        n = int(input())
        matx = []
        for i in range(n):
            x = list(input())
            matx.append(x)
        x = matx[n-2][n-1]
        y = matx[n-1][n-2]
        a = matx[0][1]
        b = matx[1][0]
        p = a+b
        q = x+y
        if x == y and a == b and x != a:
            print(0)
        elif (p == '00' and q == '00') or (p == '11' and q == '11'):
            print(2)
            print(1, 2)
            print(2, 1)
        elif (p == '10' and q == '10') or (p == '01' and q == '01'):
            print(2)
            print(1, 2)
            print(n, n-1)
        elif (p == '01' and q == '10') or (p == '10' and q == '01'):
            print(2)
            print(1, 2)
            print(n-1, n)
        elif (p=='01' and q=='00') or (p=='10' and q=='11'):
            print(1)
            print(1,2)
        elif (p == '01' and q == '11') or (p == '10' and q=='00'):
            print(1)
            print(2,1)
        elif (p == '00' or p == '11') and q == '10':
            print(1)
            print(n, n-1)
        elif (p == '00' or p == '11') and q == '01':
            print(1)
            print(n-1, n)


if __name__ == "__main__":
    main()
