#!/usr/bin/env pypy3

def ans(N, grid):
    a = grid[1][2]
    b = grid[2][1]
    c = grid[N-2][N-1]
    d = grid[N-1][N-2]

    a = int(a)
    b = int(b)
    c = int(c)
    d = int(d)

    def flipa():
        print(2, 3)

    def flipb():
        print(3, 2)

    def flipc():
        print(N-1, N)

    def flipd():
        print(N, N-1)

    if a == b and c == d:
        if b == c:
            print(2)
            flipa()
            flipb()
            return
        else:
            print(0)
            return

    if a == b:
        if c == a:
            print(1)
            flipc()
            return
        elif d == a:
            flipd()
            return
        else:
            assert(False)

    if c == d:
        if a == c:
            print(1)
            flipa()
            return
        elif b == c:
            print(1)
            flipb()
            print(3, 2)
            return

    if a == d:
        assert(b == c)
        print(2)
        flipa()
        flipc()
        return

    if a == c:
        assert(b == d)
        print(2)
        flipa()
        flipd()
        return

    assert(False)

for _ in range(int(input())):
    N = int(input())

    grid = []
    for _ in range(N):
        row = input()
        grid += [row]

    ans(N, grid)
