from collections import defaultdict
from functools import reduce
from bisect import bisect_right
from bisect import bisect_left
import copy
import atexit, io, sys
def main():
    buffer = io.BytesIO() 
    sys.stdout = buffer

    @atexit.register 
    def write(): 
        sys.__stdout__.write(buffer.getvalue())
    for _ in xrange(input()):
        n=input()
        d={}
        ans=defaultdict(list)
        c=0
        for i in xrange(n):
            d[i]=map(str," ".join(raw_input()).split())
        if d[0][1]==d[1][0]:
            if d[n-1][n-2]==d[0][1]:
                ans[c].append(n)
                ans[c].append(n-1)
                c+=1
            if d[n-2][n-1]==d[0][1]:
                ans[c].append(n-1)
                ans[c].append(n)
                c+=1
        elif d[n-1][n-2]==d[n-2][n-1]:
            if d[0][1]==d[n-1][n-2]:
                ans[c].append(1)
                ans[c].append(2)
                c+=1
            if d[1][0]==d[n-1][n-2]:
                ans[c].append(2)
                ans[c].append(1)
                c+=1
        else:
            if d[0][1]=='1':
                ans[c].append(1)
                ans[c].append(2)
                c+=1
            if d[1][0]=='1':
                ans[c].append(2)
                ans[c].append(1)
                c+=1
            if d[n-1][n-2]=='0':
                ans[c].append(n)
                ans[c].append(n-1)
                c+=1
            if d[n-2][n-1]=='0':
                ans[c].append(n-1)
                ans[c].append(n)
                c+=1
        if c==0:
            print 0
        else:
            print c 
            for i in  range(c):
                print " ".join(map(str,ans[i]))


if __name__ == '__main__':
    main()