for __ in range(int(input())):
    n = int(input())
    ar = []
    for i in range(n):
        ar.append(list(input()))
    ans = []
    if ar[0][1] != ar[n - 2][n - 1]:
        ans.append([n, n - 1])
    if ar[1][0] != ar[n - 1][n - 2]:
        ans.append([n - 1, n])
    print(len(ans))
    for elem in ans:
        print(*elem)