test_case = input()
t, t1, t2 = 0, 0, 0
posi, posj = 0, 0
def Get_Matrix(n):
	global posi, posj, t, t1, t2
        a = []
	m = int(n/2) 
	#a = [[0 for x in xrange(n+1)] for x in xrange(n+1)]
        for i in range(n):
                #j = 0
                #a[i][j], a[i][j+1], a[i][j+2], a[i][j+3], a[i][j+4] = raw_input()
		
		a.append(map(str, raw_input()))
	for i in range(n):
		for j in range(n):
			if a[i][j] == '*':
				posi, posj = i, j
	#print posi, posj	
	#print m, m
	
	if posi < m:
		t1 = m - posi
	if posi >=  m:
		t1 = posi - m
	if posj < m:
		t2 = m - posj
	if posj >= m:
		t2 = posj - m

	t = t1 + t2
	print t
	a = []
		
for k in range(test_case):
	n = input()
	Get_Matrix(n)