testcases = int(input())
arr  = []
def dfs(i , j ):
    global arr 
    if i == 0 and j == 0 :
        return True
    if i < 0 or j < 0:
        return False
    if arr[i][j] == "1":
        return False
    firstans = dfs(i - 1 ,j)
    secans = dfs(i , j - 1)
    
    if firstans or secans:
        return True 
    
    return False
    
    
    
    

for testcase in range(testcases):
    temparr = input()
    n = int(temparr)
    arr = []
    for i in range(n):
        temparr = input()
        col = []
        for i in temparr:
            col.append(i)
        arr.append(col[::])
        
    upcol = int(arr[n - 2][n - 1])
    leftcol = int(arr[n - 1][n - 2])
    adjcol = int(arr[n - 2][n - 2])
    
    if upcol == 0 and leftcol == 0 and adjcol == 1:
        print(2)
        print(str(n - 1) + " " + str(n ))
        print(str(n ) + " " + str(n - 1))
        continue 
    if upcol == 1 and leftcol == 0 and adjcol == 0:
        print(2)
        print(str(n ) + " " + str(n - 1))
        print(str(n - 1) + " " + str(n - 1))
        continue 
    
    if upcol == 0 and leftcol == 1 and adjcol == 0:
        print(2)
        print(str(n - 1 ) + " " + str(n ))
        print(str(n - 1) + " " + str(n - 1))
        continue 
    
    if upcol == 1 and leftcol == 1 and adjcol == 0 :
        print(0)
        continue 

    upcol = int(arr[n - 2][n - 1])
    leftcol = int(arr[n - 1][n - 2])
    adjcol = int(arr[n - 2][n - 2])
    
    adjcolzero = dfs(n - 2 , n - 2)
    upzero =    dfs(n - 2 , n - 1)
    leftzero = dfs(n - 1, n - 2)
    
    countans = 0 
    ansarr = []
    
    
    # if adjcolzero :
    #     arr[n-2][n-2] = 1 
    #     countans +=1 
    #     ansarr.append([str(n - 1), str(n - 1)])
        
    if upzero :
        arr[n-2][n-1] = 1 
        countans +=1 
        ansarr.append([str(n - 1), str(n)])
    
    if leftzero:
        arr[n - 1][n - 2] = 1 
        countans +=1 
        ansarr.append([str(n), str(n - 1)])
    print(countans)
    
    for tup in ansarr:
        print(" ".join(tup))
        
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    