from math import *
t=int(input())
for _ in range(t):
    n=int(input())
    l=[]
    for i in range(n):
        a=list(input())
        if i==0:
            l.append(a[1])
        elif i==1:
            l.append(a[0])
        if i==n-2:
            l.append(a[n-1])
        if i==n-1:
            l.append(a[n-2])
    if l[0]==l[1]:
        if l[0]=='0':
            if l[2]==l[3]:
                if l[2]=='1':
                    print(0)
                else:
                    print(2)
                    print(n-1,n)
                    print(n,n-1)
            elif l[2]!=l[3]:
                if l[2]=='0':
                    print(1)
                    print(n-1,n)
                else:
                    print(1)
                    print(n,n-1)
        else:
            if l[2]==l[3]:
                if l[2]=='0':
                    print(0)
                else:
                    print(2)
                    print(n-1,n)
                    print(n,n-1)
            elif l[2]!=l[3]:
                if l[2]=='1':
                    print(1)
                    print(n-1,n)
                else:
                    print(1)
                    print(n,n-1)
    else:
        if l[0]=='1':
            if l[2]==l[3]:
                if l[2]=='1':
                    print(1)
                    print(1,2)
                else:
                    print(1)
                    print(2,1)
            else:
                if l[2]=='1':
                    print(2)
                    print(1,2)
                    print(n,n-1)
                else:
                    print(2)
                    print(1,2)
                    print(n-1,n)
        else:
            if l[2]==l[3]:
                if l[2]=='0':
                    print(1)
                    print(1,2)
                else:
                    print(1)
                    print(2,1)
            else:
                if l[2]=='0':
                    print(2)
                    print(1,2)
                    print(n-1,n)
                else:
                    print(2)
                    print(1,2)
                    print(n,n-1)
                
            
            