for _ in range(int(input())):
    n=int(input())
    grid=[]
    for i in range(n):
        rows=input()
        grid.append(rows)
    x1,x2,x3,x4=grid[0][1],grid[1][0],grid[-1][-2],grid[-2][-1]
    if x1==x2==x3==x4:
        print(2)
        print(1,2)
        print(2,1)
    elif x1==x2 and x3==x4:
        print(0)
    elif x1==x3 and x2==x4:
        print(2)
        print(1,2)
        print(n,n-1)
    elif x1==x4 and x2==x3:
        print(2)
        print(1,2)
        print(n,n-1)
    elif x1==x2==x3:
        print(1)
        print(n-1,n)
    elif x1==x2==x4:
        print(1)
        print(n-1,n)
    else:
        print(1)
        print(2,1)