def rl():
    return list(map(int,input().split()))
def arp(arr):
    return ' '.join([str(i) for i in arr])

from collections import deque,Counter
from math import ceil,sqrt,log2,log,floor

for _ in range(int(input())):
    n, = rl()
    i = 0
    ans = []
    while i<n:
        s = input()
        if i<=1:
            if i==0:
                ans.append(s[1])
            else:
                ans.append(s[0])
        if i>=n-2:
            if i==n-2:
                ans.append(s[-1])
            else:
                ans.append(s[-2])
        i+=1
    cout = []
    if ans[0]!=ans[-1] and ans[1]!=ans[-2]:
        print(0)
    else:
#         print(ans)
        if ans[0]==ans[-1] and ans[1]==ans[-2]:
            cout.extend([(1,2),(2,1)])
        elif ans[0]==ans[-1] and ans[1]!=ans[-2]:
            if ans[-2]=='0':
                
                cout.append((2,1))
            else:
                cout.append((n-1,n))
        else:
            if ans[1]=='0':
                cout.append((n-1,n))
            else:
                cout.append((n,n-1))
                
            
            
            
        print(len(cout))
        for i in cout:
            print(*i)