t=int(input())

for _ in range(t):
	n=int(input())
	m=[0 for i in range(n)]
	for i in range(n):
		zz=str(input())
		if i==0:
			zz='0'+zz[1:]
		elif i==n-1:
			zz=zz[:-1]+'0'	
		m[i]=[int(i) for i in zz]
	ans=[]
	d=[m[0][2],m[1][1],m[2][0]]
	c=[(0,2),(1,1),(2,0)]
	cc=[(0,1),(1,0)]
	z=set(d)
	if m[0][1]==m[1][0]:
		if len(z)==1:
			if m[2][0]==m[0][1]:
				ans.append((1,2))
				ans.append((2,1))

		elif len(z)==2:
			for i,j in c:
				if m[i][j]==m[0][1]:
					ans.append((i+1,j+1))
	else:
		if len(z)==1:
			for i,j in cc:
				if m[i][j]!=d[0]:
					ans.append((i+1,j+1))
		else:
			tt=0
			for i,j in c:
				if m[i][j]==0:
					tt+=1

			if tt==1 or tt==0:
				for i,j in cc:
					if m[i][j]==0:
						ans.append((i+1,j+1))
				for i,j in c:
					if m[i][j]==0:
						ans.append((i+1,j+1))
			else:
				for i,j in cc:
					if m[i][j]==1:
						ans.append((i+1,j+1))
				for i,j in c:
					if m[i][j]==1:
						ans.append((i+1,j+1))
	print(len(ans))
	for i in range(len(ans)):
		print(*ans[i])