t = int(raw_input())
for i in range(t):
	n = int(raw_input())
	mid = (n+1)/2 -1
	r=0
	c=0
	for j in range(n):
		l = raw_input()
		if "*" in l:
			r=j
			for k in range(len(l)):
				if(l[k]=="*"): c=k
			
		else:
			continue
	print(abs(mid-r)+abs(mid-c))