for _ in range(input()):
    n = input()
    grid = []
    ans = []
    for i in range(n): grid.append(raw_input())
    if grid[0][1] == grid[1][0]:
        if grid[-1][-2] == grid[-2][-1]:
            if grid[0][1] == grid[-1][-2]:
                ans.append((1, 2))
                ans.append((2, 1))
        else:
            if grid[-1][-2] == grid[0][1]:
                ans.append((n, n - 1))
            else:
                ans.append((n - 1, n))
    else:
        if grid[-1][-2] == grid[-2][-1]:
            if grid[0][1] == grid[-2][-1]:
                ans.append((1, 2))
            else:
                ans.append((2, 1))
        else:
            if grid[0][1] == '1':
                ans.append((1, 2))
            if grid[1][0] == '1':
                ans.append((2, 1))
            if grid[-1][-2] == '0':
                ans.append((n, n - 1))
            if grid[-2][-1] == '0':
                ans.append((n - 1, n))
    print len(ans)
    for i in ans:
        print i[0], i[1]