m = {
    "0000": (3, 4),
    "0001": (3,),
    "0010": (4,),
    "0011": (),
    "0100": (1,),
    "0101": (2, 3),
    "0110": (2, 4),
    "0111": (2,),
    "1000": (2,),
    "1001": (2, 4),
    "1010": (2, 3),
    "1011": (1,),
    "1100": (),
    "1101": (4,),
    "1110": (3,),
    "1111": (3, 4)
}

t = int(input())
for _ in range(t):
    n = int(input())
    f = [list(input()) for _ in range(n)]
    c11 = f[0][1]
    c12 = f[1][0]
    c21 = f[-2][-1]
    c22 = f[-1][-2]
    s = f"{c11}{c12}{c21}{c22}"
    r = m[s]
    print(len(r))
    for rr in r:
        if (rr == 1):
            print("1 2")
        elif (rr == 2):
            print("2 1")
        elif (rr == 3):
            print(f"{n - 1} {n}")
        else:
            print(f"{n} {n - 1}")
        