for __ in range(int(input())):
    n = int(input())
    arr = []
    for i in range(n):
        arr.append([s for s in list(input())])
    
    x1, y1, x2, y2 = arr[0][1], arr[1][0], arr[n - 2][n - 1], arr[n-1][n - 2]
    if x1 == y1 and x2 == y2 and x1 != x2:
        print(0)
    if x1 == y1:
        if x1 == '1':
            if x2 == y2 == '1':
                print(2)
                print(n-1, n)
                print(n, n-1)
            elif x2 != y2:
                print(1)
                if x2 == '1':
                    print(n-1, n)
                else:
                    print(n, n-1)
        else:
            if x2 == y2:
                print(2)
                print(n-1, n)
                print(n, n-1)
            elif x2 != y2:
                print(1)
                if x2 == '1':
                    print(n, n-1)
                else:
                   print(n-1, n)
    elif x1 != y1:
        if x1 != x2:
            if y1 != y2:
                print(2)
                print(n, n-1)
                print(1, 0)
            else:
                print(1)
                print(1, 0)
        else:
            if y1 == y2:
                print(2)
                print(n-1, n)
                print(1, 0)
            else:
                print(1)
                print(0, 1)




            
