#: Author - Soumya Saurav
import sys,io,os,time
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

input = sys.stdin.readline

########################################
for ii in range(int(input())):
	n = int(input())
	arr = []
	for i in range(n):
		arr.append(input())
	ans = []
	if arr[0][1] == "1" and arr[1][0] == "1":
		if arr[n-1][n-2] == "1":
			ans.append([n,n-1])
		if arr[n-2][n-1] == "1":
			ans.append([n-1,n])
	else:
		if arr[n-1][n-2] == "0":
			ans.append([n,n-1])
		if arr[n-2][n-1] == "0":
			ans.append([n-1,n])
	print(len(ans))
	for i in range(len(ans)):
		print(*ans[i])








'''
# Wrap solution for more recursion depth
#submit as python3
import collections,sys,threading
sys.setrecursionlimit(10**9)
threading.stack_size(10**8)



threading.Thread(target=solve).start()
'''
