t=int(input())
for i in range(0,t):
    n=int(input())
    a=[]
    for j in range(0,n):
        b=input()
        q=[b[k] for k in range(0,n)]
        a.append(q)
    if(n!=0):
        c=[a[0][1],a[1][0],a[n-1][n-2],a[n-2][n-1]]
        x1=int(a[0][1])+int(a[1][0])
        x2=int(a[n-1][n-2])+int(a[n-2][n-1])
        if(x1==2):
            if(x2==0):
                print(0)
                continue
            if(x2==2):
                print(2)
                print(n,n-1)
                print(n-1,n)
                continue
            if(x2==1):
                if(c[2]=='1'):
                    print(1)
                    print(n,n-1)
                    continue
                if(c[3]=='1'):
                    print(1)
                    print(n-1,n)
                    continue
        if(x1==0):
            if(x2==2):
                print(0)
                continue 
            if(x2==0):
                print(2)
                print(n-0,n-1)
                print(n-1,n-0)
                continue
            if(x2==1):
                if(c[2]=='0'):
                    print(1)
                    print(n-0,n-1)
                    continue
                if(c[3]=='0'):
                    print(1)
                    print(n-1,n)
                    continue
        if(x2==0):
            if(x1==2):
                print(0)
                continue 
            if(x1==0):
                print(2)
                print(1,2)
                print(2,1)
                continue
            if(x1==1):
                if(c[0]=='0'):
                    print(1)
                    print(1,2)
                    continue
                if(c[1]=='0'):
                    print(1)
                    print(2,1)
                    continue
        if(x2==2):
            if(x1==0):
                print(0)
                continue
            if(x1==2):
                print(2)
                print(1,2)
                print(2,1)
                continue
            if(x1==1):
                if(c[0]=='1'):
                    print(1)
                    print(1,2)
                    continue
                if(c[1]=='1'):
                    print(1)
                    print(2,1)
                    continue
        if(x1==1 and x2==1):
            print(2)
            if(c[0]=='1'):
                    print(1,2)
            if(c[1]=='1'):
                    print(2,1)
            if(c[2]=='0'):
                    print(n,n-1)
            if(c[3]=='0'):
                    print(n-1,n-0)
    else:
        print(0)