import math
t = int(input())

for _ in range(t):
	n = int(input())
	grid = []
	for i in range(n):
		grid.append(list(input()))
	
	cnt = 0
	ans = []
	
	if grid[n-1][n-2] != grid[n-2][n-1]:
		cnt += 1
		print("1")
		ans += [(n-1,n)]
	
	if grid[n-1][n-2] == grid[n-2][n-2]:
		cnt += 1
		print("2")
		ans += [(n-1,n-1)]
	
	print(cnt)
	for i in range(cnt):
		print(ans[i][0],ans[i][1])
	
