'''
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineering College

'''
from os import path
import sys
from heapq import heappush,heappop
from functools import cmp_to_key as ctk
from collections import deque,defaultdict as dd 
from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
from itertools import permutations
from datetime import datetime
from math import ceil,sqrt,log,gcd
def ii():return int(input())
def si():return input().rstrip()
def mi():return map(int,input().split())
def li():return list(mi())
abc='abcdefghijklmnopqrstuvwxyz'
# mod=1000000007
mod=998244353
inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]

def bo(i):
    return ord(i)-ord('a')

def ceil(a,b):
    return (a+b-1)//b
file=1

def f():
    sys.stdout.flush()


def solve():


    
    for _ in range(ii()):

        n = ii()
        a = []
        for i in range(n):
            a.append(si())
        ans = set()
        if a[0][1] != a[1][0]:
            ans.add((1,2))
            if a[n-2][n-1] == a[1][0]:
                ans.add((n-1,n))
            if a[n-1][n-2] == a[1][0]:
                ans.add((n,n-1))
        else:
            if a[n-2][n-1] == a[1][0]:
                ans.add((n-1,n))
            if a[n-1][n-2] == a[1][0]:
                ans.add((n,n-1))
        print(len(ans))
        for i in ans:
            print(*i)



        
        









        
if __name__ =="__main__":

   
    if path.exists('input.txt'):
        sys.stdin=open('input.txt', 'r')
        sys.stdout=open('output.txt','w')
    else:
        input=sys.stdin.readline
    solve()
