for _ in range(int(input())):
    n=int(input())
    ar=[]
    for i in range(n):
        ar.append(list(input()))
    ans=[]
    se=[]
    for i in range(n):
        tem=[]
        for j in range(n):
            tem.append(0)
        se.append(tem.copy())
    ne=[[0,0]]
    ty='0'
    while(ne):
        tem=[]
        for i in ne:
            xx=i[0]
            yy=i[1]
            if(xx!=0):
                if(ar[xx-1][yy]=='F'):
                    ans.append([xx+1,yy+1])
                if(se[xx-1][yy]==0 and ar[xx-1][yy]==ty):
                    se[xx-1][yy]=1
                    tem.append([xx-1,yy])
            if(xx!=(n-1)):
                if(ar[xx+1][yy]=='F'):
                    ans.append([xx+1,yy+1])
                if(se[xx+1][yy]==0 and ar[xx+1][yy]==ty):
                    se[xx+1][yy]=1
                    tem.append([xx+1,yy])
            if(yy!=(n-1)):
                if(ar[xx][yy+1]=='F'):
                    ans.append([xx+1,yy+1])
                if(se[xx][yy+1]==0 and ar[xx][yy+1]==ty):
                    se[xx][yy+1]=1
                    tem.append([xx,yy+1])
            if(yy!=0):
                if(ar[xx][yy-1]=='F'):
                    ans.append([xx+1,yy+1])
                if(se[xx][yy-1]==0 and ar[xx][yy-1]==ty):
                    se[xx][yy-1]=1
                    tem.append([xx,yy-1])
        ne=tem.copy()
    se=[]
    for i in range(n):
        tem=[]
        for j in range(n):
            tem.append(0)
        se.append(tem.copy())
    ne=[[0,0]]
    ty='1'
    while(ne):
        tem=[]
        for i in ne:
            xx=i[0]
            yy=i[1]
            if(xx!=0):
                if(ar[xx-1][yy]=='F'):
                    ans.append([xx+1,yy+1])
                if(se[xx-1][yy]==0 and ar[xx-1][yy]==ty):
                    se[xx-1][yy]=1
                    tem.append([xx-1,yy])
            if(xx!=(n-1)):
                if(ar[xx+1][yy]=='F'):
                    ans.append([xx+1,yy+1])
                if(se[xx+1][yy]==0 and ar[xx+1][yy]==ty):
                    se[xx+1][yy]=1
                    tem.append([xx+1,yy])
            if(yy!=(n-1)):
                if(ar[xx][yy+1]=='F'):
                    ans.append([xx+1,yy+1])
                if(se[xx][yy+1]==0 and ar[xx][yy+1]==ty):
                    se[xx][yy+1]=1
                    tem.append([xx,yy+1])
            if(yy!=0):
                if(ar[xx][yy-1]=='F'):
                    ans.append([xx+1,yy+1])
                if(se[xx][yy-1]==0 and ar[xx][yy-1]==ty):
                    se[xx][yy-1]=1
                    tem.append([xx,yy-1])
        ne=tem.copy()
    print(len(ans))
    for i in ans:
        print(*i)