for _ in range(int(input())):
    n = int(input())
    g = [input() for _ in range(n)]

    if (g[0][1] + g[1][0] + g[-1][-2] + g[-2][-1]).count('0') in (0, 4):
        print(2)
        print(1, 2)
        print(2, 1)
        continue

    if (g[0][1] + g[1][0] + g[-1][-2] + g[-2][-1]).count('0') == 2:
        if g[0][1] == g[-1][-2]:
            print(2)
            print(1, 2)
            print(n, n-1)
            continue

        if g[1][0] == g[-1][-2]:
            print(2)
            print(2, 1)
            print(n, n-1)
            continue

        if g[0][1] == g[-2][-1]:
            print(2)
            print(1, 2)
            print(n-1, n)
            continue

        if g[1][0] == g[-2][-1]:
            print(2)
            print(2, 1)
            print(n-1, n)
            continue

        print(0)
        continue

    if g[0][1] == g[1][0]:
        if g[-1][-2] == g[0][1]:
            print(1)
            print(n, n-1)

        if g[-2][-1] == g[0][1]:
            print(1)
            print(n-1, n)

        continue

    if g[-1][-2] == g[-2][-1]:
        if g[0][1] == g[-1][-2]:
            print(1)
            print(1, 2)

        if g[1][0] == g[-1][-2]:
            print(1)
            print(2, 1)

        continue
    