for _ in range(int(input())):
    '''
S0101
10000
01111
11110
0001F
    '''
    n = int(input())
    lst = []
    for _ in range(n):
        lst.append(input())
    if lst[0][1] == lst[1][0] and lst[-1][-2] == lst[-2][-1]:
        if lst[0][1] == lst[-1][-2]:
            print(2)
            print(1,2)
            print(2,1)
            # correct
        else:
            print(0)
            # correct
    elif lst[0][1] != lst[1][0] and lst[-1][-2] != lst[-2][-1]:
        if lst[0][1] == '1':
            # make it 0
            print(2)
            print(1,2)
            if lst[-1][-2] == '1':
                print(n-1,n)
            else:
                print(n,n-1)
        else:
            print(2)
            print(2,1)
            if lst[-1][-2] == '1':
                print(n-1,n)
            else:
                print(n,n-1)
    elif lst[0][1] == lst[1][0]:
        print(1)
        if lst[0][1] == '0':
            # it is 0 so convert bottom to 1
            if lst[-1][-2] == '1':
                print(n-1,n)
            else:
                print(n,n-1)
        else:
            # convert to 0
            if lst[-1][-2] == '0':
                print(n-1,n)
            else:
                print(n,n-1)
    else:
        # if bottom are same 
        print(1)
        if lst[-1][-2] == '0':
            # it is 0 so convert top to 1
            if lst[0][1] == '0':
                print(0,1)
            else:
                print(1,0)
        else:
            # convert to 1
            if lst[0][1] == '1':
                print(0,1)
            else:
                print(1,0)
