t = int(input())
for i in range(t):
    list1 = []
    n = int(input())
    for j in range(n):
        list1.append(input())
    s_right = list1[0][1]
    s_down = list1[1][0]
    f_left = list1[-1][-2]
    f_up = list1[-2][-1]
    
    if s_right==s_down and f_left==f_up:
        if s_right!=f_left:
            print(0)
        else:
            print(2)
            print(n-1,' ',n)
            print(n,' ',n-1)
    elif s_right!=s_down and f_left==f_up:
        if s_right==f_left:
            print(1)
            print(1,' ',2)
        elif s_down==f_left:
            print(1)
            print(2,' ',1)
    elif s_right==s_down and f_left!=f_up:
        if s_right==f_left:
            print(1)
            print(n,' ',n-1)
        elif s_down==f_up:
            print(1)
            print(n-1,' ',n)
    else:
        print(2)
        if s_right==f_up:
            print(1,' ',2)
            print(n,' ',n-1)
        elif s_right==f_left:
            print(1,' ',2)
            print(n-1,' ',n)
        