def Block(n, arr):
    a=arr[0][1]
    b=arr[1][0]
    c=arr[-1][-2]
    d=arr[-2][-1]
    count=0
    l=[]
    
    if a=='0' and b=='0':
        if c=='1' and d=='1':
            return count, l
        elif c=='0' and d=='0':
            count+=2
            l.append((0, 1))
            l.append((1, 0))
        elif c=='1' and d=='0':
            count+=1
            l.append((n-2, n-1))
        else:
            count+=1
            l.append((n-1, n-2))
            
    if a=='1' and b=='1':
        if c=='0' and d=='0':
            return count, l
        elif c=='1' and d=='1':
            count+=2
            l.append((0, 1))
            l.append((1, 0))
        elif c=='1' and d=='0':
            count+=1
            l.append((n-1, n-2))
        else:
            count+=1
            l.append((n-2, n-1))
            
    if a=='1' and b=='0':
        if c=='1' and d=='1':
            count+=1
            l.append((0, 1))
        elif c=='0' and d=='0':
            count+=1
            l.append((1, 0))
        else:
            if c=='1':
                count+=2
                l.append((1, 0))
                l.append((n-1, n-2))
            else:
                count+=2
                l.append((0, 1))
                l.append((n-1, n-2))
                
    if a=='0' and b=='1':
        if c=='1' and d=='1':
            count+=1
            l.append((1, 0))
        elif c=='0' and d=='0':
            count+=1
            l.append((0, 1))
        else:
            if c=='1':
                count+=2
                l.append((0, 1))
                l.append((n-1, n-2))
            else:
                count+=2
                l.append((1, 0))
                l.append((n-2, n-1))
                
    return count, l




t=int(input())
for _ in range(t):
    n=int(input())
    arr=[]
    for j in range(n):
        new_row=input()
        arr.append(list(new_row))
    c,l=Block(n, arr)
    print(c)
    for i in l:
             print(i[0]+1, i[1]+1)