import queue

t = int(input())

def bfs(dig,grid,n):		

	d = [[1000 for j in range(n)] for i in range(n)]
	d[0][0] = 0
	q = queue.Queue()
	q.put((0,0))

	while (not q.empty()):
		i,j = q.get()		
		if (i+1 < n and (grid[i+1][j] == dig or grid[i+1][j] == 'F') and d[i+1][j] == 1000):
			q.put((i+1,j))
			d[i+1][j] = d[i][j] + 1
		if (j+1 < n and (grid[i][j+1] == dig or grid[i][j+1] == 'F') and d[i][j+1] == 1000):
			q.put((i,j+1))
			d[i][j+1] = d[i][j] + 1
		if (i-1 >= 0 and grid[i-1][j] == dig and d[i-1][j] == 1000):
			q.put((i-1,j))
			d[i-1][j] = d[i][j] + 1
		if (j-1 >= 0 and grid[i][j-1] == dig and d[i][j-1] == 1000):
			q.put((i,j-1))
			d[i][j-1] = d[i][j] + 1

	return d



while (t):

	n = int(input())

	grid = []
	for i in range(n):
		grid.append(input())

	d0 = bfs('0',grid,n)
	d1 = bfs('1',grid,n)
	z = [[d0[i][j] != 1000 or d1[i][j] != 1000 for j in range(n)] for i in range(n)]


	if (z[-1][-2] and z[-2][-1]):
		print(2)
		print(n,n-1)
		print(n-1,n)
	elif (z[-1][-2]):
		print(1)
		print(n,n-1)
	elif (z[-2][-1]):
		print(1)
		print(n-1,n)
	else:
		print(0)	

	t -= 1
			
	
	