for u in range(int(input())):
    n = int(input())
    x = []
    for i in range(n):
        x.append(input())
        
    l = []
    if(x[0][1] == '0' and x[1][0] == '0'):
        if(x[n-1][n-2] == '0'):
            l.append([n, n-1])
        
        if(x[n-2][n-1] == '0'):
            l.append([n-1, n])
            
    elif(x[n-1][n-2] == '0' and x[n-2][n-1] == '0'):
        if(x[0][1] == "0"):
            l.append([1, 2])
            
        if(x[1][0] == '0'):
            l.append([2, 1])
            
    elif(x[n-1][n-2] == '1' and x[n-2][n-1] == '1'):
        if(x[0][1] == "1"):
            l.append([1, 2])
            
        if(x[1][0] == '1'):
            l.append([2, 1])
            
    elif(x[0][1] == '1' and x[1][0] == '1'):
        if(x[n-1][n-2] == '1'):
            l.append([n, n-1])
        
        if(x[n-2][n-1] == '1'):
            l.append([n-1, n])
            
    else:
        if(x[0][1] == '1'):
            l.append([1, 2])
        
        if(x[1][0] == '1'):
            l.append([2, 1])
            
        if(x[n-1][n-2] == '1'):
            l.append([n, n-1])
            
        if(x[n-2][n-1] == '1'):
            l.append([n-1, n])
            
    print(len(l))
    for i in l:
        print(i[0], i[1])