There is a square field of size $n \times n$ in which two cells are marked. These cells can be in the same row or column.

You are to mark two more cells so that they are the corners of a rectangle with sides parallel to the coordinate axes.

For example, if $n=4$ and a rectangular field looks like this (there are asterisks in the marked cells):

$$ \begin{matrix} . & . & * & . \\ . & . & . & . \\ * & . & . & . \\ . & . & . & . \\ \end{matrix} $$

Then you can mark two more cells as follows

$$ \begin{matrix} * & . & * & . \\ . & . & . & . \\ * & . & * & . \\ . & . & . & . \\ \end{matrix} $$

If there are several possible solutions, then print any of them.


-----Input-----

The first line contains a single integer $t$ ($1 \le t \le 400$). Then $t$ test cases follow.

The first row of each test case contains a single integer $n$ ($2 \le n \le 400$) — the number of rows and columns in the table.

The following $n$ lines each contain $n$ characters '.' or '*' denoting empty and marked cells, respectively.

It is guaranteed that the sums of $n$ for all test cases do not exceed $400$.

It is guaranteed that there are exactly two asterisks on the field. They can be in the same row/column.

It is guaranteed that the solution exists.


-----Output-----

For each test case, output $n$ rows of $n$ characters — a field with four asterisks marked corresponding to the statements. If there multiple correct answers, print any of them.


-----Examples-----

Input
6
4
..*.
....
*...
....
2
*.
.*
2
.*
.*
3
*.*
...
...
5
.....
..*..
.....
.*...
.....
4
....
....
*...
*...
Output
*.*.
....
*.*.
....
**
**
**
**
*.*
*.*
...
.....
.**..
.....
.**..
.....
....
....
**..
**..


-----Note-----

None

Source: codeforces | Difficulty: EASY
Tags: Implementation


Solutions:
t = int(input())
for inh in range(0, t):
	n = int(input())
	(row, column, c) = ([], [], 0)
	for inhg in range(0, n):
		s = input()
		if '*' in s and c < 2:
			for i in range(0, n):
				if s[i] == '*':
					row.append(inhg)
					column.append(i)
					c += 1
	if row[0] == row[1]:
		if row[0] == 0:
			row.append(1)
			row.append(1)
		else:
			row.append(0)
			row.append(0)
	elif column[0] == column[1]:
		if column[0] == 0:
			column.append(1)
			column.append(1)
		else:
			column.append(0)
			column.append(0)
	else:
		row.append(row[0])
		row.append(row[1])
		column.append(column[1])
		column.append(column[0])
	for i in range(0, n):
		if i in row:
			for j in range(0, n):
				if j in column:
					print('*', end='')
				else:
					print('.', end='')
			print('')
		else:
			print('.' * n)


for i in range(int(input())):
	n = int(input())
	mat = []
	for i in range(n):
		mat.append(list(map(str, input())))
	l = []
	for i in range(n):
		for j in range(n):
			if mat[i][j] == '*':
				l.append(i)
				l.append(j)
	(x, y, a, b) = l
	if x == a and x != n - 1:
		mat[x + 1][y] = '*'
		mat[a + 1][b] = '*'
	if x == a and x == n - 1:
		mat[x - 1][y] = '*'
		mat[a - 1][b] = '*'
	if y == b and y != n - 1:
		mat[x][y + 1] = '*'
		mat[a][b + 1] = '*'
	if y == b and y == n - 1:
		mat[x][y - 1] = '*'
		mat[a][b - 1] = '*'
	mat[a][y] = '*'
	mat[x][b] = '*'
	s = ''
	for i in range(n):
		for j in range(n):
			s += mat[i][j]
		print(s)
		s = ''


for _ in range(int(input())):
	n = int(input())
	l = list()
	r = list()
	for i in range(n):
		k = list(input())
		l.append(k)
	for i in range(n):
		if '*' in l[i]:
			if l[i].count('*') > 1:
				for t in range(n):
					if l[i][t] == '*':
						k = []
						k.append(i)
						k.append(t)
						r.append(k)
				break
			else:
				k = []
				k.append(i)
				k.append(l[i].index('*'))
				r.append(k)
	fr = r[0][0]
	fc = r[0][1]
	sr = r[1][0]
	sc = r[1][1]
	if fr == sr:
		try:
			l[fr + 1][fc] = '*'
			l[sr + 1][sc] = '*'
		except:
			l[fr - 1][fc] = '*'
			l[sr - 1][sc] = '*'
	elif fc == sc:
		try:
			l[fr][fc + 1] = '*'
			l[sr][sc + 1] = '*'
		except:
			l[fr][fc - 1] = '*'
			l[sr][sc - 1] = '*'
	else:
		l[fr][sc] = '*'
		l[sr][fc] = '*'
	for i in range(n):
		for j in range(n):
			print(l[i][j], end='')
		print()


for tc in range(int(input())):
	n = int(input())
	a = []
	for i in range(n):
		a.append(list(input()))
	t = [i.count('*') for i in a]
	if 2 in t:
		on = t.index(2)
		dot = [i for i in range(len(a[on])) if a[on][i] == '*']
		if on == 0:
			for i in dot:
				a[1][i] = '*'
			for i in a:
				print(''.join(i))
		if on != 0:
			for i in dot:
				a[0][i] = '*'
			for i in a:
				print(''.join(i))
	else:
		k = [i for i in range(n) if t[i] == 1]
		k1 = a[k[0]].index('*')
		k2 = a[k[1]].index('*')
		if k1 == k2:
			if k1 == 0:
				a[k[0]][1] = '*'
				a[k[1]][1] = '*'
			else:
				a[k[0]][0] = '*'
				a[k[1]][0] = '*'
			for i in a:
				print(''.join(i))
		else:
			a[k[0]][k2] = '*'
			a[k[1]][k1] = '*'
			for i in a:
				print(''.join(i))


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from bisect import insort
from collections import Counter
from collections import deque
from heapq import heappush, heappop, heapify
from itertools import permutations, combinations
from itertools import accumulate as ac
mod = int(1000000000.0) + 7
mod = 998244353
ip = lambda : int(stdin.readline())
inp = lambda : map(int, stdin.readline().split())
ips = lambda : stdin.readline().rstrip()
out = lambda x: stdout.write(str(x) + '\n')
t = ip()
for _ in range(t):
	n = ip()
	arr = []
	for i in range(n):
		s = ips()
		arr.append(list(s))
	ct = [[0] * n for i in range(n)]
	ind = []
	for i in range(n):
		for j in range(n):
			if arr[i][j] == '*':
				ind.append([i, j])
	val1 = ind[0]
	val2 = ind[1]
	if val1[0] == val2[0]:
		if val1[0] == 0:
			arr[1][val1[1]] = '*'
			arr[1][val2[1]] = '*'
		else:
			arr[0][val1[1]] = '*'
			arr[0][val2[1]] = '*'
	elif val1[1] == val2[1]:
		if val1[1] == 0:
			arr[val1[0]][1] = '*'
			arr[val2[0]][1] = '*'
		else:
			arr[val1[0]][0] = '*'
			arr[val2[0]][0] = '*'
	else:
		for i in ind:
			x = i[0]
			y = i[1]
			for i in range(n):
				if y != i:
					ct[x][i] += 1
				if x != i:
					ct[i][y] += 1
			ct[x][y] += 1
		ans = []
		for i in range(n):
			for j in range(n):
				if ct[i][j] == 2:
					ans.append([i, j])
		for i in ans:
			arr[i[0]][i[1]] = '*'
	for i in arr:
		print(''.join(i))


for _ in range(int(input())):
	n = int(input())
	a = [[c for c in l] for l in [input() for __ in range(n)]]
	r1 = c1 = r2 = c2 = -1
	for (r, l) in enumerate(a):
		for (c, e) in enumerate(l):
			if e == '*':
				if r1 == -1:
					r1 = r
					c1 = c
				else:
					r2 = r
					c2 = c
					break
	if r1 == r2:
		if r1 > 0:
			a[r1 - 1][c1] = '*'
			a[r1 - 1][c2] = '*'
		else:
			a[r1 + 1][c1] = '*'
			a[r1 + 1][c2] = '*'
	elif c1 == c2:
		if c1 > 0:
			a[r1][c1 - 1] = '*'
			a[r2][c1 - 1] = '*'
		else:
			a[r1][c1 + 1] = '*'
			a[r2][c1 + 1] = '*'
	else:
		a[r1][c2] = '*'
		a[r2][c1] = '*'
	for l in a:
		print(''.join(l))


for _ in range(int(input())):
	n = int(input())
	a = []
	l = []
	for i in range(n):
		s = input()
		s1 = list(s)
		a.append(s1)
		for j in range(n):
			if s1[j] == '*':
				l.append([i, j])
	x1 = l[0][0]
	y1 = l[0][1]
	x2 = l[1][0]
	y2 = l[1][1]
	if x1 == x2:
		if x1 != n - 1:
			a[n - 1][y1] = '*'
			a[n - 1][y2] = '*'
		else:
			a[0][y1] = '*'
			a[0][y2] = '*'
	elif y1 == y2:
		if y1 != n - 1:
			a[x1][n - 1] = '*'
			a[x2][n - 1] = '*'
		else:
			a[x1][0] = '*'
			a[x2][0] = '*'
	else:
		a[l[0][0]][l[1][1]] = '*'
		a[l[1][0]][l[0][1]] = '*'
	for i in range(n):
		s = ''.join(a[i])
		print(s)


T = int(input())
for _ in range(T):
	n = int(input())
	mat = []
	f = 0
	for i in range(n):
		s = list(input())
		mat.append(s)
		for j in range(n):
			if s[j] == '*':
				if f == 0:
					(x1, y1) = (i, j)
					f = 1
				else:
					(x2, y2) = (i, j)
					break
	if y1 == y2:
		if y1 == 0:
			mat[x1][y1 + 1] = '*'
			mat[x2][y1 + 1] = '*'
		else:
			mat[x1][y1 - 1] = '*'
			mat[x2][y1 - 1] = '*'
	elif x1 == x2:
		if x1 == 0:
			mat[x1 + 1][y1] = '*'
			mat[x1 + 1][y2] = '*'
		else:
			mat[x1 - 1][y1] = '*'
			mat[x1 - 1][y2] = '*'
	else:
		mat[x1][y2] = '*'
		mat[x2][y1] = '*'
	for i in mat:
		s = ''
		for j in i:
			s += j
		print(s)


def solve(n, grid):
	stars = list()
	for (i, row) in enumerate(grid):
		for (j, cell) in enumerate(row):
			if cell == '*':
				stars.append((i, j))
	assert len(stars) == 2
	((r1, c1), (r2, c2)) = stars
	if r1 != r2 and c1 != c2:
		grid[r1][c2] = '*'
		grid[r2][c1] = '*'
	elif r1 == r2 and c1 != c2:
		new_row = 1 if r1 == 0 else 0
		grid[new_row][c1] = '*'
		grid[new_row][c2] = '*'
	else:
		new_col = 1 if c1 == 0 else 0
		grid[r1][new_col] = '*'
		grid[r2][new_col] = '*'
	return grid

def main():
	for _ in range(int(input())):
		n = int(input())
		grid = [list(input()) for _ in range(n)]
		ans = solve(n, grid)
		for row in ans:
			print(''.join(row))
main()


import sys
input = sys.stdin.readline
ins = lambda : input().rstrip()
ini = lambda : int(input().rstrip())
inm = lambda : map(int, input().rstrip().split())
inl = lambda : list(map(int, input().split()))
out = lambda x, s='\n': print(s.join(map(str, x)))
t = ini()
for _ in range(t):
	n = ini()
	b = []
	a = [list(ins()) for i in range(n)]
	for y in range(n):
		for x in range(n):
			if a[y][x] == '*':
				b.append([y, x])
	if b[0][0] == b[1][0]:
		if b[0][0] == 0:
			b[0][0] += 1
			b[1][0] += 1
		else:
			b[0][0] -= 1
			b[1][0] -= 1
	elif b[0][1] == b[1][1]:
		if b[0][1] == 0:
			b[0][1] += 1
			b[1][1] += 1
		else:
			b[0][1] -= 1
			b[1][1] -= 1
	else:
		(b[0][0], b[0][1], b[1][0], b[1][1]) = (b[0][0], b[1][1], b[1][0], b[0][1])
	a[b[0][0]][b[0][1]] = '*'
	a[b[1][0]][b[1][1]] = '*'
	out([''.join(i) for i in a])


def printField(field):
	for line in field:
		print(''.join(line))
for t in range(int(input())):
	n = int(input())
	field = []
	for i in range(n):
		field.append(list(input()))
	asterixes = []
	for y in range(len(field)):
		for x in range(len(field[y])):
			if field[y][x] == '*':
				asterixes.append((y, x))
	a = asterixes[0]
	b = asterixes[1]
	if a[0] != b[0] and a[1] != b[1]:
		field[a[0]][b[1]] = '*'
		field[b[0]][a[1]] = '*'
		printField(field)
		continue
	else:
		if a[0] == b[0]:
			cy = a[0] - 1
			if cy < 0:
				cy += 2
			field[cy][b[1]] = '*'
			field[cy][a[1]] = '*'
		else:
			cx = a[1] - 1
			if cx < 0:
				cx += 2
			field[a[0]][cx] = '*'
			field[b[0]][cx] = '*'
		printField(field)
		continue


for _ in range(int(input())):
	n = int(input())
	l = []
	for i in range(n):
		l.append(list(input()))
	x = []
	for j in range(n):
		for k in range(n):
			if l[j][k] == '*':
				x.append([j, k])
	if x[0][0] == x[1][0]:
		if x[0][0] == 0:
			l[1][x[0][1]] = '*'
			l[1][x[1][1]] = '*'
		elif x[0][0] == n - 1:
			l[n - 2][x[0][1]] = '*'
			l[n - 2][x[1][1]] = '*'
		else:
			l[x[0][0] + 1][x[0][1]] = '*'
			l[x[0][0] + 1][x[1][1]] = '*'
	elif x[0][1] == x[1][1]:
		if x[0][1] == 0:
			l[x[0][0]][1] = '*'
			l[x[1][0]][1] = '*'
		elif x[0][1] == n - 1:
			l[x[0][0]][n - 2] = '*'
			l[x[1][0]][n - 2] = '*'
		else:
			l[x[0][0]][x[0][1] + 1] = '*'
			l[x[1][0]][x[0][1] + 1] = '*'
	else:
		l[x[0][0]][x[1][1]] = '*'
		l[x[1][0]][x[0][1]] = '*'
	for ss in range(n):
		for sss in range(n):
			print(l[ss][sss], end='')
		print()


import copy
import math
fin = None
fout = None
uabet = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
abet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

def start(filename):
	filename = filename.replace('.py', '')
	global fin
	global fout
	infile = filename + '.in'
	outfile = filename + '.out'
	fin = open(infile)
	fout = open(outfile, 'w')

def permutation(lst):
	if len(lst) == 0:
		return []
	if len(lst) == 1:
		return [lst]
	l = []
	for i in range(len(lst)):
		m = lst[i]
		remLst = lst[:i] + lst[i + 1:]
		for p in permutation(remLst):
			l.append([m] + p)
	return l

def subsets(x):
	retset = []
	if len(x) == 0:
		retset = [[]]
	else:
		first = x[-1]
		cop = x.copy()
		cop.remove(first)
		y = subsets(cop)
		retset.extend(copy.deepcopy(y))
		m = copy.deepcopy(y)
		for i in range(len(y)):
			k = m[0]
			m.remove(k)
			k.append(first)
			m.append(k)
		retset.extend(m.copy())
	return retset

class Point:

	def __init__(self, x, y):
		self.x = x
		self.y = y

	def __str__(self):
		return str(self.x) + str(self.y)

	def __hash__(self):
		return hash(str(self))

	def __eq__(self, other):
		return self.x == other.x and self.y == other.y

class frac:

	def __init__(self, n, d):
		self.n = n
		self.d = d

	def __str__(self):
		return str(self.n) + '/' + str(self.d)

	def __hash__(self):
		return hash(str(self))

	def simp(self):
		div = math.gcd(self.n, self.d)
		self.n = self.n / div
		self.d = self.d / div

	def __eq__(self, other):
		return self.n / self.d == other.n / other.d

	def __lt__(self, other):
		return self.n / self.d < other.n / other.d

class Interval:

	def __init__(self, start, end):
		self.start = start
		self.end = end

	def __str__(self):
		return str(self.start) + str(self.end)

	def __hash__(self):
		return hash(str(self))

	def __eq__(self, other):
		return self.start == other.start and self.end == other.end

	def __lt__(self, other):
		return self.start < other.start

def overlap(verl1, verl2):
	if verl1.end >= verl2.start:
		return True
	else:
		return False

def merge(verl1, verl2):
	retverl = Interval(min(verl1.start, verl2.start), max(verl1.end, verl2.end))
	return retverl

def changeBase(num, base):
	if base == 2:
		return '{0:b}'.format(num)
	power = math.floor(math.log(num, base))
	remainder = num
	end = []
	iter = list(range(power + 1))
	iter.reverse()
	for i in iter:
		if remainder >= base ** i:
			(q, r) = divmod(remainder, base ** i)
			end.append(q)
			remainder = r
		else:
			end.append(0)
	retlist = []
	for i in end:
		if i > 9:
			retlist.append(uabet[i - 10])
		else:
			retlist.append(i)
	retlist = map(str, retlist)
	return ''.join(retlist)

def prime(num):
	if num == 2:
		return True
	if num % 2 == 0:
		return False
	for i in range(2, math.ceil(num ** 0.5) + 1):
		if num % i == 0:
			return False
	return True

def solve(n, g):
	c = []
	for i in range(n):
		for j in range(n):
			if g[i][j] == '*':
				c.append([i, j])
	if c[0][0] == c[1][0]:
		if c[0][0] + 1 < n:
			c.append([c[0][0] + 1, c[0][1]])
			c.append([c[1][0] + 1, c[1][1]])
		elif c[0][0] - 1 >= 0:
			c.append([c[0][0] - 1, c[0][1]])
			c.append([c[1][0] - 1, c[1][1]])
	elif c[0][1] == c[1][1]:
		if c[0][1] + 1 < n:
			c.append([c[0][0], c[0][1] + 1])
			c.append([c[1][0], c[1][1] + 1])
		elif c[0][1] - 1 >= 0:
			c.append([c[0][0], c[0][1] - 1])
			c.append([c[1][0], c[1][1] - 1])
	else:
		c.append([c[0][0], c[1][1]])
		c.append([c[1][0], c[0][1]])
	for i in range(n):
		l = ''
		for j in range(n):
			if [i, j] in c:
				l += '*'
			else:
				l += '.'
		print(l)

def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		a = []
		for j in range(n):
			a.append(list(input()))
		solve(n, a)
main()


def find(A, B):
	returnValue = -1
	for index in range(len(B)):
		if B[index] == A:
			returnValue = index
			break
	return returnValue
t = int(input())
n = [1 for i in range(t)]
coord = [[] for i in range(t)]
a = [[] for i in range(t)]
for i in range(t):
	n[i] = int(input())
	a[i] = ['bruh'] * n[i]
	for j in range(n[i]):
		a[i][j] = input()
		a[i][j] = list(a[i][j])
	j = 0
	count = 0
	while j < n[i]:
		if find('*', a[i][j]) != -1:
			count += 1
			coord[i].append([j, find('*', a[i][j])])
			a[i][j][find('*', a[i][j])] = '.'
			j -= 1
			if count == 2:
				break
		j += 1
for i in range(t):
	x1 = coord[i][0][0]
	x2 = coord[i][1][0]
	y1 = coord[i][0][1]
	y2 = coord[i][1][1]
	a[i][x1][y1] = '*'
	a[i][x2][y2] = '*'
	if x1 == x2:
		try:
			a[i][x1 + 1][y1] = '*'
			a[i][x2 + 1][y2] = '*'
		except:
			a[i][x1 - 1][y1] = '*'
			a[i][x2 - 1][y2] = '*'
	elif y1 == y2:
		try:
			a[i][x1][y1 + 1] = '*'
			a[i][x2][y2 + 1] = '*'
		except:
			a[i][x1][y1 - 1] = '*'
			a[i][x2][y2 - 1] = '*'
	else:
		a[i][x2][y1] = '*'
		a[i][x1][y2] = '*'
	for j in range(n[i]):
		for k in range(n[i]):
			print(a[i][j][k], end='')
		print()


tot = int(input())
for x in range(tot):
	a = int(input())
	idar = []
	for y in range(a):
		b = input()
		if len(idar) < 4:
			for pp in range(a):
				if b[pp] == '*':
					idar.append(y)
					idar.append(pp)
	nid = []
	if idar[0] == idar[2]:
		if idar[0] == a - 1:
			nid.append(idar[0] - 1)
			nid.append(idar[1])
			nid.append(idar[2] - 1)
			nid.append(idar[3])
		else:
			nid.append(idar[0] + 1)
			nid.append(idar[1])
			nid.append(idar[2] + 1)
			nid.append(idar[3])
	elif idar[1] == idar[3]:
		if idar[1] == a - 1:
			nid.append(idar[0])
			nid.append(idar[1] - 1)
			nid.append(idar[2])
			nid.append(idar[3] - 1)
		else:
			nid.append(idar[0])
			nid.append(idar[1] + 1)
			nid.append(idar[2])
			nid.append(idar[3] + 1)
	else:
		nid.append(idar[0])
		nid.append(idar[3])
		nid.append(idar[2])
		nid.append(idar[1])
	pp = idar[0]
	qq = idar[1]
	rr = idar[2]
	ss = idar[3]
	tt = nid[0]
	uu = nid[1]
	vv = nid[2]
	ww = nid[3]
	for ff in range(a):
		for hh in range(a):
			if pp == ff and qq == hh or (rr == ff and ss == hh) or (tt == ff and uu == hh) or (vv == ff and ww == hh):
				print('*', end='')
			else:
				print('.', end='')
		print()


for x in range(int(input())):
	n = int(input())
	a = []
	l = [[0 for i in range(n)] for j in range(n)]
	for i in range(n):
		s = input()
		for j in range(n):
			if s[j] == '*':
				a.append([i, j])
			l[i][j] = s[j]
	x1 = a[0][0]
	y1 = a[0][1]
	x2 = a[1][0]
	y2 = a[1][1]
	if x1 == x2:
		if x1 == 0:
			l[x1 + 1][y1] = '*'
			l[x2 + 1][y2] = '*'
		elif x1 == n - 1:
			l[x1 - 1][y1] = '*'
			l[x2 - 1][y2] = '*'
		else:
			l[x1 + 1][y1] = '*'
			l[x2 + 1][y2] = '*'
	elif y1 == y2:
		if y1 == 0:
			l[x1][y1 + 1] = '*'
			l[x2][y2 + 1] = '*'
		elif x1 == n - 1:
			l[x1][y1 - 1] = '*'
			l[x2][y2 - 1] = '*'
		else:
			l[x1][y1 - 1] = '*'
			l[x2][y2 - 1] = '*'
	else:
		l[x1][y2] = '*'
		l[x2][y1] = '*'
	for i in l:
		for j in range(len(i)):
			print(i[j], end='')
		print()


def mapa(A, N):
	A = list(map(list, A))
	(p1, p2) = (None, None)
	for i in range(N):
		for j in range(N):
			if A[i][j] == '*':
				if p1 == None:
					p1 = (i, j)
				else:
					p2 = (i, j)
	if p1[0] == p2[0]:
		if p1[0] != N - 1:
			A[p1[0] + 1][p1[1]] = '*'
			A[p1[0] + 1][p2[1]] = '*'
			return A
		else:
			A[p1[0] - 1][p1[1]] = '*'
			A[p1[0] - 1][p2[1]] = '*'
			return A
	if p1[1] == p2[1]:
		if p1[1] != N - 1:
			A[p1[0]][p1[1] + 1] = '*'
			A[p2[0]][p2[1] + 1] = '*'
			return A
		else:
			A[p1[0]][p1[1] - 1] = '*'
			A[p2[0]][p2[1] - 1] = '*'
			return A
	else:
		A[p1[0]][p2[1]] = '*'
		A[p2[0]][p1[1]] = '*'
		return A

def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		a = []
		for i in range(n):
			a.append(input())
		for wyn in mapa(a, n):
			print(''.join(wyn))
main()


for _ in range(0, int(input())):
	n = int(input())
	c = []
	for i in range(0, n):
		s = input()
		c += [[i, w] for (w, x) in enumerate(s) if x == '*']
	ofr = 0
	ofc = 0
	if c[0][0] == c[1][0]:
		ofr = -1 if c[0][0] > 0 else 1
	if c[0][1] == c[1][1]:
		ofc = -1 if c[0][1] > 0 else 1
	c.append([c[0][0] + ofr, c[1][1] + ofc])
	c.append([c[1][0] + ofr, c[0][1] + ofc])
	d = []
	for w in range(0, n):
		v = ['.'] * n
		for x in c:
			if w == x[0]:
				v[x[1]] = '*'
		d.append(v)
	for w in d:
		print(''.join(w))


num = int(input())
for _ in range(num):
	n = int(input())
	arrays = []
	for i in range(n):
		arr = [str(x) for x in input()]
		arrays.append(arr)
	star = []
	for i in range(n):
		for j in range(n):
			if arrays[i][j] == '*':
				star.append([i, j])
	(x1, y1) = (star[0][0], star[0][1])
	(x2, y2) = (star[1][0], star[1][1])
	if x1 == x2:
		if x1 - 1 >= 0:
			arrays[x1 - 1][y1] = '*'
			arrays[x2 - 1][y2] = '*'
		else:
			arrays[x1 + 1][y1] = '*'
			arrays[x2 + 1][y2] = '*'
	elif y1 == y2:
		if y1 - 1 >= 0:
			arrays[x1][y1 - 1] = '*'
			arrays[x2][y2 - 1] = '*'
		else:
			arrays[x1][y1 + 1] = '*'
			arrays[x2][y2 + 1] = '*'
	else:
		arrays[x1][y2] = '*'
		arrays[x2][y1] = '*'
	for i in range(len(arrays)):
		str1 = ''.join(arrays[i])
		print(str1)


t = int(input())
for i in range(t):
	n = int(input())
	matrix = ['' for x in range(n)]
	(x1, x2, y1, y2) = (1000000000.0, 0, 1000000000.0, 0)
	(xx1, xx2, yy1, yy2) = (0, 0, 0, 0)
	for r in range(n):
		matrix[r] = input()
		for c in range(n):
			if matrix[r][c] == '*':
				if r < x1:
					x1 = r
				if r > x2:
					x2 = r
				if c < y1:
					y1 = c
				if c > y2:
					y2 = c
	if x1 == x2:
		if x1 < n - 1:
			(xx1, xx2) = (x1 + 1, x1 + 1)
		else:
			(xx1, xx2) = (x1 - 1, x1 - 1)
	else:
		xx1 = min(x1, x2)
		xx2 = max(x1, x2)
	if y1 == y2:
		if y1 < n - 1:
			(yy1, yy2) = (y1 + 1, y2 + 1)
		else:
			(yy1, yy2) = (y1 - 1, y2 - 1)
	else:
		yy1 = min(y1, y2)
		if matrix[xx1][yy1] == '*':
			yy1 = max(y1, y2)
			yy2 = min(y1, y2)
		else:
			yy2 = max(y1, y2)
	matrix[xx1] = matrix[xx1][0:yy1] + '*' + matrix[xx1][yy1 + 1:]
	matrix[xx2] = matrix[xx2][0:yy2] + '*' + matrix[xx2][yy2 + 1:]
	for mx in matrix:
		print(mx)


I = input
e = enumerate
for _ in [0] * int(I()):
	n = int(I())
	r = [[*I()] for _ in [0] * n]
	((i, j), (k, l)) = [(i, j) for (i, s) in e(r) for (j, x) in e(s) if '.' > x]
	k = (k + (k == i)) % n
	l = (l + (l == j)) % n
	r[k][l] = r[i][l] = r[k][j] = '*'
	for s in r:
		print(*s, sep='')


import sys

def solve_tc():
	n = int(input())
	hight1 = -1
	rar1 = 0
	hight2 = 0
	rar2 = 0
	matrix = []
	for i in range(n):
		s = list(input())
		matrix.append(s)
		for el in range(len(s)):
			if s[el] == '*':
				if hight1 == -1:
					hight1 = i
					rar1 = el
				elif el == rar1:
					if el != 1:
						hight2 = i
						rar1 = rar2 = 1
					else:
						hight2 = i
						rar2 = rar1 = 0
				elif hight1 == i:
					if hight1 != 1:
						hight2 = hight1 = 1
					else:
						hight2 = hight1 = 0
					rar2 = el
				else:
					rar2 = el
					hight2 = i
	matrix[hight2][rar1] = '*'
	matrix[hight1][rar2] = '*'
	for i in matrix:
		sys.stdout.write(''.join(map(str, i)))
		sys.stdout.write('\n')
t = int(input())
while t > 0:
	t -= 1
	solve_tc()


for _ in range(int(input())):
	n = int(input())
	grid = [[char for char in input()] for _ in range(n)]
	marks = []
	for (y, row) in enumerate(grid):
		for (x, col) in enumerate(row):
			if col == '*':
				marks.append((x, y))
	if marks[0][0] == marks[1][0]:
		grid[marks[0][1]][(marks[0][0] + 1) % n] = '*'
		grid[marks[1][1]][(marks[0][0] + 1) % n] = '*'
	elif marks[0][1] == marks[1][1]:
		grid[(marks[0][1] + 1) % n][marks[0][0]] = '*'
		grid[(marks[1][1] + 1) % n][marks[1][0]] = '*'
	else:
		grid[marks[0][1]][marks[1][0]] = '*'
		grid[marks[1][1]][marks[0][0]] = '*'
	for row in grid:
		print(''.join(row))


for _ in range(int(input())):
	n = int(input())
	arr = []
	for i in range(n):
		temp = list(input())
		arr.append(temp)
	pos1 = -1
	pos2 = -1
	for i in range(n):
		for j in range(n):
			if arr[i][j] == '*':
				if pos1 == -1:
					pos1 = [i, j]
				else:
					pos2 = [i, j]
					break
	if pos1[0] == pos2[0]:
		if pos1[0] + 1 < n:
			arr[pos1[0] + 1][pos1[1]] = '*'
			arr[pos2[0] + 1][pos2[1]] = '*'
		else:
			arr[pos1[0] - 1][pos1[1]] = '*'
			arr[pos2[0] - 1][pos2[1]] = '*'
	elif pos1[1] == pos2[1]:
		if pos1[1] + 1 < n:
			arr[pos1[0]][pos1[1] + 1] = '*'
			arr[pos2[0]][pos2[1] + 1] = '*'
		else:
			arr[pos1[0]][pos1[1] - 1] = '*'
			arr[pos2[0]][pos2[1] - 1] = '*'
	else:
		arr[pos1[0]][pos2[1]] = '*'
		arr[pos2[0]][pos1[1]] = '*'
	for i in range(n):
		s = ''
		print(s.join(arr[i]))


for _ in range(int(input())):
	len_side = int(input())
	mat = []
	for line in range(len_side):
		mat.append(list(input()))
	tmp = []
	cnt = 0
	for (i, line) in enumerate(mat):
		for (j, v) in enumerate(line):
			if v == '*':
				tmp.append([i, j])
				cnt += 1
			if cnt == 2:
				break
	if tmp[0][0] == tmp[1][0]:
		if tmp[0][0] == len_side - 1:
			mat[tmp[0][0] - 1][tmp[0][1]] = '*'
			mat[tmp[0][0] - 1][tmp[1][1]] = '*'
		else:
			mat[tmp[0][0] + 1][tmp[0][1]] = '*'
			mat[tmp[0][0] + 1][tmp[1][1]] = '*'
	elif tmp[0][1] == tmp[1][1]:
		if tmp[1][1] == len_side - 1:
			mat[tmp[0][0]][tmp[1][1] - 1] = '*'
			mat[tmp[1][0]][tmp[1][1] - 1] = '*'
		else:
			mat[tmp[0][0]][tmp[1][1] + 1] = '*'
			mat[tmp[1][0]][tmp[1][1] + 1] = '*'
	else:
		mat[tmp[0][0]][tmp[1][1]] = '*'
		mat[tmp[1][0]][tmp[0][1]] = '*'
	for line in mat:
		print(''.join(line))


import sys, math, itertools, random, bisect
from collections import defaultdict
INF = 10 ** 18

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def input():
	return sys.stdin.readline().strip()
mod = 10 ** 9 + 7
for _ in range(int(input())):
	n = int(input())
	a = []
	for i in range(n):
		s = list(input())
		a.append(s)
	star = []
	for i in range(n):
		for j in range(n):
			if a[i][j] == '*':
				star.append([i, j])
	(x1, y1) = (star[0][0], star[0][1])
	(x2, y2) = (star[1][0], star[1][1])
	if x1 == x2:
		if x1 == n - 1:
			x = 0
		else:
			x = n - 1
		star.append([x, y1])
		star.append([x, y2])
	elif y1 == y2:
		if y1 == 0:
			y = n - 1
		else:
			y = 0
		star.append([x1, y])
		star.append([x2, y])
	else:
		star.append([x1, y2])
		star.append([x2, y1])
	for (x, y) in star:
		a[x][y] = '*'
	for i in a:
		print(''.join(i))


import os
import sys
from io import BytesIO, IOBase
from collections import Counter
import math as mt
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def lcm(a, b):
	return a * b / gcd(a, b)
mod = int(1000000000.0) + 7

def power(k, n):
	if n == 0:
		return 1
	if n % 2:
		return power(k, n - 1) * k % mod
	t = power(k, n // 2)
	return t * t % mod

def totalPrimeFactors(n):
	count = 0
	if n % 2 == 0:
		count += 1
		while n % 2 == 0:
			n //= 2
	i = 3
	while i * i <= n:
		if n % i == 0:
			count += 1
			while n % i == 0:
				n //= i
		i += 2
	if n > 2:
		count += 1
	return count

def main():
	for _ in range(int(input())):
		n = int(input())
		a = []
		st = []
		for i in range(n):
			t = input()
			k = []
			c = 0
			for j in t:
				if j == '*' or j == '.':
					k.append(j)
					if j == '*':
						st.append([i, c])
				c += 1
			a.append(k)
		if st[0][0] == st[1][0]:
			if st[0][0]:
				a[st[0][0] - 1][st[0][1]] = '*'
				a[st[0][0] - 1][st[1][1]] = '*'
			else:
				a[st[0][0] + 1][st[0][1]] = '*'
				a[st[0][0] + 1][st[1][1]] = '*'
		elif st[0][1] == st[1][1]:
			if st[0][1]:
				a[st[0][0]][st[0][1] - 1] = '*'
				a[st[1][0]][st[1][1] - 1] = '*'
			else:
				a[st[0][0]][st[0][1] + 1] = '*'
				a[st[1][0]][st[1][1] + 1] = '*'
		else:
			st.sort()
			a[st[0][0]][st[1][1]] = '*'
			a[st[1][0]][st[0][1]] = '*'
		for i in a:
			for j in i:
				print(j, end='')
			print('')
	return
main()


from collections import defaultdict, OrderedDict, Counter
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
from queue import Queue, PriorityQueue
from heapq import *
from statistics import *
from math import *
import fractions
import copy
from copy import deepcopy
import sys
import io
sys.setrecursionlimit(10000)
import math
import os
import bisect
import collections
mod = pow(10, 9) + 7
import random
from random import *
from time import time

def ncr(n, r, p=mod):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def normalncr(n, r):
	r = min(r, n - r)
	count = 1
	for i in range(n - r, n + 1):
		count *= i
	for i in range(1, r + 1):
		count //= i
	return count
inf = float('inf')
adj = defaultdict(set)
visited = defaultdict(int)

def addedge(a, b):
	adj[a].add(b)
	adj[b].add(a)

def bfs(v):
	q = Queue()
	q.put(v)
	visited[v] = 1
	while q.qsize() > 0:
		s = q.get_nowait()
		print(s)
		for i in adj[s]:
			if visited[i] == 0:
				q.put(i)
				visited[i] = 1

def dfs(v, visited):
	if visited[v] == 1:
		return
	visited[v] = 1
	print(v)
	for i in adj[v]:
		dfs(i, visited)

def reverse_bisect_right(a, x, lo=0, hi=None):
	if lo < 0:
		raise ValueError('lo must be non-negative')
	if hi is None:
		hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if x > a[mid]:
			hi = mid
		else:
			lo = mid + 1
	return lo

def reverse_bisect_left(a, x, lo=0, hi=None):
	if lo < 0:
		raise ValueError('lo must be non-negative')
	if hi is None:
		hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if x >= a[mid]:
			hi = mid
		else:
			lo = mid + 1
	return lo

def get_list():
	return list(map(int, input().split()))

def get_str_list_in_int():
	return [int(i) for i in list(input())]

def get_str_list():
	return list(input())

def get_map():
	return map(int, input().split())

def input_int():
	return int(input())

def matrix(a, b):
	return [[0 for i in range(b)] for j in range(a)]

def swap(a, b):
	return (b, a)

def find_gcd(l):
	a = l[0]
	for i in range(len(l)):
		a = gcd(a, l[i])
	return a

def is_prime(n):
	sqrta = int(sqrt(n))
	for i in range(2, sqrta + 1):
		if n % i == 0:
			return 0
	return 1

def prime_factors(n):
	while n % 2 == 0:
		return [2] + prime_factors(n // 2)
	sqrta = int(sqrt(n))
	for i in range(3, sqrta + 1, 2):
		if n % i == 0:
			return [i] + prime_factors(n // i)
	return [n]

def p(a):
	if type(a) == str:
		print(a + '\n')
	else:
		print(str(a) + '\n')

def ps(a):
	if type(a) == str:
		print(a)
	else:
		print(str(a))

def kth_no_not_div_by_n(n, k):
	return k + (k - 1) // (n - 1)

def forward_array(l):
	n = len(l)
	stack = []
	forward = [0] * n
	for i in range(len(l) - 1, -1, -1):
		while len(stack) and l[stack[-1]] < l[i]:
			stack.pop()
		if len(stack) == 0:
			forward[i] = len(l)
		else:
			forward[i] = stack[-1]
		stack.append(i)
	return forward

def backward_array(l):
	n = len(l)
	stack = []
	backward = [0] * n
	for i in range(len(l)):
		while len(stack) and l[stack[-1]] < l[i]:
			stack.pop()
		if len(stack) == 0:
			backward[i] = -1
		else:
			backward[i] = stack[-1]
		stack.append(i)
	return backward
nc = 'NO'
yc = 'YES'
ns = 'No'
ys = 'Yes'
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
for i in range(int(input())):
	n = int(input())
	l = [0] * n
	m = []
	for i in range(n):
		l[i] = list(input())
		for b in range(n):
			if l[i][b] == '*':
				a = i
				m.append([a, b])
	if m[0][0] == m[1][0] or m[0][1] == m[1][1]:
		if m[0][0] == m[1][0]:
			horizontal = 1
			if m[0][0] == 0:
				x1 = 1
				y1 = m[0][1]
				l[x1][y1] = '*'
				y1 = m[1][1]
				l[x1][y1] = '*'
			else:
				x1 = 0
				y1 = m[0][1]
				l[x1][y1] = '*'
				y1 = m[1][1]
				l[x1][y1] = '*'
		elif m[0][1] == 0:
			y1 = 1
			x1 = m[0][0]
			l[x1][y1] = '*'
			x1 = m[1][0]
			l[x1][y1] = '*'
		else:
			y1 = 0
			x1 = m[0][0]
			l[x1][y1] = '*'
			x1 = m[1][0]
			l[x1][y1] = '*'
	else:
		x1 = m[0][0]
		y1 = m[1][1]
		l[x1][y1] = '*'
		x1 = m[1][0]
		y1 = m[0][1]
		l[x1][y1] = '*'
	for i in l:
		print(''.join(i))


def soln(matrix, n):
	r = []
	c = []
	for i in range(n):
		if len(r) == 2:
			break
		for j in range(n):
			if matrix[i][j] == '*':
				r.append(i)
				c.append(j)
	if r[0] == r[1]:
		if r[0] == 0:
			matrix[1] = matrix[0]
		else:
			matrix[r[0] - 1] = matrix[r[0]]
	elif c[0] == c[1]:
		string = ''
		if c[0] == 0:
			for i in range(n):
				if i == c[0] or i == c[0] + 1:
					string += '*'
				else:
					string += '.'
		else:
			for i in range(n):
				if i == c[0] or i == c[0] - 1:
					string += '*'
				else:
					string += '.'
		matrix[r[0]] = string
		matrix[r[1]] = string
	else:
		string = ''
		for i in range(n):
			if i == c[0] or i == c[1]:
				string += '*'
			else:
				string += '.'
		matrix[r[0]] = string
		matrix[r[1]] = string
	return matrix
t = int(input())
for _ in range(t):
	n = int(input())
	matrix = []
	for i in range(n):
		arr = input()
		matrix.append(arr)
	matrix = soln(matrix, n)
	for i in matrix:
		print(i)


from sys import stdin
input = stdin.readline
for test in range(int(input())):
	n = int(input())
	lst = [''] * n
	store = []
	for i in range(n):
		lst[i] = input().strip()
		if '*' in lst[i]:
			store.append([i, lst[i].index('*')])
	l = len(store)
	if l == 2:
		if store[0][1] == store[1][1]:
			if store[0][1] == 0:
				temp = lst[store[0][0]]
				temp = '**' + temp[2:]
				lst[store[0][0]] = temp
				lst[store[1][0]] = temp
			else:
				temp = lst[store[0][0]]
				temp = temp[:store[0][1] - 1] + '**' + temp[store[0][1] + 1:]
				lst[store[0][0]] = temp
				lst[store[1][0]] = temp
		temp = lst[store[0][0]]
		temp = temp[:store[1][1]] + '*' + temp[store[1][1] + 1:]
		lst[store[0][0]] = temp
		temp = lst[store[1][0]]
		temp = temp[:store[0][1]] + '*' + temp[store[0][1] + 1:]
		lst[store[1][0]] = temp
	else:
		try:
			lst[store[0][0] + 1] = lst[store[0][0]]
		except IndexError:
			lst[store[0][0] - 1] = lst[store[0][0]]
	print(*lst, sep='\n')


def solve(arr):
	(x1, x2, y1, y2) = (None, None, None, None)
	(x3, x4, y3, y4) = (None, None, None, None)
	for i in range(len(arr)):
		for j in range(len(arr[0])):
			if arr[i][j] == '*':
				if x1 is not None:
					x2 = i
					y2 = j
				else:
					x1 = i
					y1 = j
	if x1 == x2:
		x3 = x1 + (-1 if x1 > 0 else 1)
		x4 = x2 + (-1 if x2 > 0 else 1)
		y3 = y1
		y4 = y2
	elif y1 == y2:
		y3 = y1 + (-1 if y1 > 0 else 1)
		y4 = y2 + (-1 if y2 > 0 else 1)
		x3 = x1
		x4 = x2
	else:
		x3 = x1
		y3 = y2
		x4 = x2
		y4 = y1
	arr[x3][y3] = '*'
	arr[x4][y4] = '*'
	arr = [''.join(r) for r in arr]
	arr = [arr[i] + ('\n' if i + 1 != len(arr) else '') for i in range(len(arr))]
	return ''.join(arr)
for i in range(int(input())):
	arr = []
	for _ in range(int(input())):
		arr += [list(input())]
	print(f'{solve(arr)}')


t = int(input())
for i in range(t):
	n = int(input())
	res = []
	s = []
	for i in range(n):
		res.append(input())
		if '*' in res[i]:
			s.append((i, res[i].find('*')))
			if res[i].count('*') > 1:
				s.append((i, res[i].rfind('*')))
	if s[0][0] == s[1][0]:
		y = n - 1 if n - 1 != s[0][0] else n - 2
		s.append((y, s[0][1]))
		s.append((y, s[1][1]))
	elif s[0][1] == s[1][1]:
		x = n - 1 if n - 1 != s[0][1] else n - 2
		s.append((s[0][0], x))
		s.append((s[1][0], x))
	else:
		s.append((s[1][0], s[0][1]))
		s.append((s[0][0], s[1][1]))
	s.sort()
	for i in range(n):
		if i == s[0][0]:
			print('.' * s[0][1] + '*' + '.' * (s[1][1] - 1 - s[0][1]) + '*' + '.' * (n - s[1][1] - 1))
		elif i == s[2][0]:
			print('.' * s[2][1] + '*' + '.' * (s[3][1] - 1 - s[2][1]) + '*' + '.' * (n - s[3][1] - 1))
		else:
			print('.' * n)


t = int(input())
while t > 0:
	n = int(input())
	s = []
	for i in range(n):
		s.append(input())
	cord = []
	for i in range(n):
		for j in range(n):
			if s[i][j] == '*':
				cord.append((i, j))
	(cord1, cord2) = cord
	if cord1[0] == cord2[0]:
		if cord1[0] == 0:
			cord.append((1, cord1[1]))
			cord.append((1, cord2[1]))
		else:
			cord.append((0, cord1[1]))
			cord.append((0, cord2[1]))
	elif cord1[1] == cord2[1]:
		if cord1[1] == 0:
			cord.append((cord1[0], 1))
			cord.append((cord2[0], 1))
		else:
			cord.append((cord1[0], 0))
			cord.append((cord2[0], 0))
	else:
		cord.append((cord1[0], cord2[1]))
		cord.append((cord2[0], cord1[1]))
	x = [i[0] for i in cord]
	y = [i[1] for i in cord]
	for i in range(n):
		for j in range(n):
			if i in x and j in y:
				print('*', end='')
			else:
				print('.', end='')
		print('')
	t -= 1


for t in range(int(input())):
	n = int(input())
	ss = []
	a = []
	one_line = 0
	for i in range(n):
		ss.append(input())
	for i in range(n):
		for j in range(n):
			if ss[i][j] == '*':
				a.append((i, j))
	if a[0][0] == a[1][0]:
		if a[0][0] == 0:
			a.append((1, a[0][1]))
			a.append((1, a[1][1]))
		else:
			a.append((a[0][0] - 1, a[0][1]))
			a.append((a[1][0] - 1, a[1][1]))
	elif a[0][1] == a[1][1]:
		if a[0][1] == 0:
			a.append((a[0][0], 1))
			a.append((a[1][0], 1))
		else:
			a.append((a[0][0], a[0][1] - 1))
			a.append((a[1][0], a[1][1] - 1))
	else:
		a.append((a[0][0], a[1][1]))
		a.append((a[1][0], a[0][1]))
	for i in range(n):
		for j in range(n):
			if (i, j) in a:
				print('*', end='')
			else:
				print('.', end='')
		print()


for _ in range(int(input())):
	n = int(input())
	(x, y) = ([], [])
	grid = []
	for r in range(n):
		grid.append(list(input().rstrip()))
		for (c, ch) in enumerate(grid[-1]):
			if ch == '*':
				x.append(r)
				y.append(c)
	if x[0] == x[1]:
		r = (x[0] + 1) % n
		for c in y:
			grid[r][c] = '*'
	elif y[0] == y[1]:
		c = (y[0] + 1) % n
		for r in x:
			grid[r][c] = '*'
	else:
		grid[x[0]][y[1]] = '*'
		grid[x[1]][y[0]] = '*'
	for i in range(n):
		print(''.join(grid[i]))


t = int(input())
for k in range(t):
	n = int(input())
	s = []
	for i in range(n):
		s.append(list(input()))
	x1 = -1
	y1 = -1
	x2 = -1
	y2 = -1
	for i in range(n):
		for j in range(n):
			if s[i][j] == '*':
				if x1 == -1:
					x1 = i
					y1 = j
				else:
					x2 = i
					y2 = j
	if x1 != x2 and y1 != y2:
		s[x1][y2] = '*'
		s[x2][y1] = '*'
	elif x1 == x2:
		x2 = (x1 + 1) % n
		s[x2][y1] = '*'
		s[x2][y2] = '*'
	elif y1 == y2:
		y2 = (y1 + 1) % n
		s[x1][y2] = '*'
		s[x2][y2] = '*'
	for i in range(n):
		print(''.join(s[i]))


for _ in range(int(input())):
	x1 = y1 = x2 = y2 = 0
	p1 = False
	p2 = False
	n = int(input())
	for i in range(n):
		l = list(input().rstrip())
		for j in range(n):
			if l[j] == '*':
				if not p1:
					x1 = i
					y1 = j
					p1 = True
				elif not p2:
					x2 = i
					y2 = j
					p2 = True
	x3 = y3 = x4 = y4 = 0
	if x1 == x2 or y1 == y2:
		if x1 == x2:
			y3 = y1
			y4 = y2
			if x1 < n - 1:
				x3 = x4 = n - 1
			else:
				x3 = x4 = 0
		elif y1 == y2:
			x3 = x1
			x4 = x2
			if y1 < n - 1:
				y3 = y4 = n - 1
			else:
				y3 = y4 = 0
	else:
		x3 = x2
		x4 = x1
		y3 = y1
		y4 = y2
	for i in range(n):
		for j in range(n):
			if i == x1 and j == y1 or (i == x2 and j == y2) or (i == x3 and j == y3) or (i == x4 and j == y4):
				print('*', end='')
			else:
				print('.', end='')
		print()


import math
from collections import defaultdict
from sys import stdout
DEBUG = True

def log(*args, **kwargs):
	if DEBUG:
		print(*args, **kwargs)

def ri():
	return int(input())

def rl(f=int):
	return list(map(f, input().split()))

def rs():
	return input()

class Solution:

	def __init__(self):
		pass

	def run(self):
		points = []
		n = ri()
		grid = []
		for i in range(n):
			row = list(rs())
			grid.append(row)
			for j in range(len(row)):
				if row[j] == '*':
					points.append([i, j])
		if points[0][0] == points[1][0]:
			x = points[0][0]
			(a, b) = (points[0][1], points[1][1])
			grid[(x + 1) % n][a] = '*'
			grid[(x + 1) % n][b] = '*'
		elif points[0][1] == points[1][1]:
			y = points[0][1]
			(a, b) = (points[0][0], points[1][0])
			grid[a][(y + 1) % n] = '*'
			grid[b][(y + 1) % n] = '*'
		else:
			(x, y) = points[0]
			(a, b) = points[1]
			grid[x][b] = '*'
			grid[a][y] = '*'
		for r in grid:
			print(''.join(r))
t = int(input())
s = Solution()
for i in range(t):
	s.run()


from collections import deque, defaultdict
from math import sqrt, ceil, factorial, floor, inf, log2, sqrt, gcd
import bisect
import sys
import copy

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
for _ in range(int(input())):
	n = int(input())
	arr = []
	for i in range(n):
		s = input()
		s = list((str(x) for x in s))
		arr.append(s)
	a = []
	for i in range(n):
		for j in range(n):
			if arr[i][j] == '*':
				a.append([i, j])
	if a[0][0] == a[1][0]:
		row = a[0][0]
		flag = 0
		if row + 1 <= n - 1:
			arr[row + 1][a[0][1]] = '*'
			arr[row + 1][a[1][1]] = '*'
			flag = 1
		if flag == 0:
			arr[row - 1][a[0][1]] = '*'
			arr[row - 1][a[1][1]] = '*'
	elif a[0][1] == a[1][1]:
		col = a[0][1]
		flag = 0
		if col + 1 <= n - 1:
			arr[a[0][0]][col + 1] = '*'
			arr[a[1][0]][col + 1] = '*'
			flag = 1
		if flag == 0:
			arr[a[0][0]][col - 1] = '*'
			arr[a[1][0]][col - 1] = '*'
	else:
		row1 = a[0][0]
		col1 = a[0][1]
		row2 = a[1][0]
		col2 = a[1][1]
		arr[row2][col1] = '*'
		arr[row1][col2] = '*'
	for i in range(n):
		print(''.join(arr[i]))


t = int(input())
for _ in range(t):
	n = int(input())
	cords = []
	matrix = []
	for i in range(n):
		temp = list(input())
		matrix.append(temp)
		j = 0
		for item in temp:
			if item == '*':
				cords.append([i, j])
			j += 1
	a = cords[0][0]
	b = cords[0][1]
	x = cords[1][0]
	y = cords[1][1]
	if a == x and a == 0:
		matrix[n - 1][b] = '*'
		matrix[n - 1][y] = '*'
	elif a == x and a != 0:
		matrix[0][b] = '*'
		matrix[0][y] = '*'
	elif b == y and b == 0:
		matrix[a][n - 1] = '*'
		matrix[x][n - 1] = '*'
	elif b == y and b != 0:
		matrix[a][0] = '*'
		matrix[x][0] = '*'
	else:
		matrix[x][b] = '*'
		matrix[a][y] = '*'
	for row in matrix:
		print(''.join(row))


for _ in range(int(input())):
	n = int(input())
	lsx = []
	ls = []
	for i in range(n):
		a = list(input())
		ls.append(a)
		for j in range(len(a)):
			if a[j] == '*':
				lsx.append([i, j])
	x1 = lsx[0][0]
	x2 = lsx[0][1]
	y1 = lsx[1][0]
	y2 = lsx[1][1]
	if x1 != y1 and x2 != y2:
		ls[x1][y2] = '*'
		ls[y1][x2] = '*'
	elif x1 == y1:
		if x1 != n - 1:
			ls[x1 + 1][x2] = '*'
			ls[y1 + 1][y2] = '*'
		else:
			ls[x1 - 1][x2] = '*'
			ls[y1 - 1][y2] = '*'
	elif x2 == y2:
		if x2 != n - 1:
			ls[x1][x2 + 1] = '*'
			ls[y1][y2 + 1] = '*'
		else:
			ls[x1][x2 - 1] = '*'
			ls[y1][y2 - 1] = '*'
	for j in range(n):
		print(''.join(ls[j]))


for _ in range(int(input())):
	n = int(input())
	li = []
	points = []
	po = []
	for i in range(n):
		x = input()
		y = []
		for j in range(n):
			if x[j] == '.':
				y.append('.')
			else:
				y.append('*')
				po.append(i)
				po.append(j)
		li.append(y)
	if po[0] != po[2] and po[1] != po[3]:
		li[po[0]][po[3]] = '*'
		li[po[2]][po[1]] = '*'
	else:
		if po[1] == po[3]:
			if po[1] + 1 != n:
				li[po[0]][po[1] + 1] = '*'
				li[po[2]][po[3] + 1] = '*'
			else:
				li[po[0]][po[1] - 1] = '*'
				li[po[2]][po[3] - 1] = '*'
		if po[0] == po[2]:
			if po[0] + 1 != n:
				li[po[0] + 1][po[1]] = '*'
				li[po[2] + 1][po[3]] = '*'
			else:
				li[po[0] - 1][po[1]] = '*'
				li[po[2] - 1][po[3]] = '*'
	for i in li:
		print(''.join(i))


n = int(input())

def solve(l):
	coord = []
	for i in range(len(l)):
		for j in range(len(l)):
			if l[i][j] == '*':
				coord.append((i, j))
	return coord
for i in range(n):
	a = int(input())
	l = []
	for i in range(a):
		l.append(list(input()))
	c = solve(l)
	x = c[0][0]
	y = c[0][1]
	x2 = c[1][0]
	y2 = c[1][1]
	if x != x2 and y != y2:
		l[x][y2] = '*'
		l[x2][y] = '*'
	elif x == x2:
		if x == a - 1:
			l[x - 1][y2] = '*'
			l[x2 - 1][y] = '*'
		else:
			l[x + 1][y2] = '*'
			l[x2 + 1][y] = '*'
	elif y == y2:
		if y == a - 1:
			l[x][y2 - 1] = '*'
			l[x2][y - 1] = '*'
		else:
			l[x][y2 + 1] = '*'
			l[x2][y + 1] = '*'
	for k in range(len(l)):
		print(''.join(l[k]))


t = int(input())
for _ in range(t):
	n = int(input())
	a = []
	for i in range(n):
		s = input()
		a.append(list(s))
	pts = []
	for i in range(n):
		for j in range(n):
			if a[i][j] == '*':
				pts.append((i, j))
	(x1, y1) = pts.pop()
	(x2, y2) = pts.pop()
	if x1 == x2:
		if x1 > 0:
			a[x1 - 1][y1] = '*'
			a[x2 - 1][y2] = '*'
		else:
			a[x1 + 1][y1] = '*'
			a[x2 + 1][y2] = '*'
	elif y1 == y2:
		if y1 > 0:
			a[x1][y1 - 1] = '*'
			a[x2][y2 - 1] = '*'
		else:
			a[x1][y1 + 1] = '*'
			a[x2][y2 + 1] = '*'
	else:
		a[x1][y2] = '*'
		a[x2][y1] = '*'
	for i in range(n):
		print(''.join(a[i]))


from collections import Counter
tc = int(input())
for _ in range(tc):
	n = int(input())
	a = [list(input()) for i in range(n)]
	st = []
	for i in range(n):
		for j in range(n):
			if a[i][j] == '*':
				st.append((i, j))
	if st[0][0] != st[1][0] and st[0][1] != st[1][1]:
		a[st[0][0]][st[1][1]] = a[st[1][0]][st[0][1]] = '*'
	elif st[0][0] == st[1][0]:
		if st[0][0] == 0:
			rrcc = 1
		else:
			rrcc = st[0][0] - 1
		a[rrcc][st[0][1]] = a[rrcc][st[1][1]] = '*'
	else:
		if st[0][1] == 0:
			rrcc = 1
		else:
			rrcc = st[0][1] - 1
		a[st[0][0]][rrcc] = a[st[1][0]][rrcc] = '*'
	a = [''.join(k) for k in a]
	print(*a, sep='\n')


for _ in range(int(input())):
	n = int(input())
	g = []
	cnt = 0
	xy = []
	for i in range(n):
		a = list(input())
		g.append(a)
		if cnt == 0:
			if '*' in a:
				t = a.index('*')
				xy.append(t)
				xy.append(i)
				k = t
				if '*' in a[t + 1:]:
					t = a[t + 1:].index('*')
					xy.append(t + k + 1)
					xy.append(i)
					cnt = cnt + 1
				cnt = cnt + 1
		elif cnt == 1:
			if '*' in a:
				xy.append(a.index('*'))
				xy.append(i)
	if xy[0] == xy[2]:
		try:
			g[xy[1]][xy[0] + 1] = '*'
			g[xy[3]][xy[2] + 1] = '*'
		except IndexError:
			g[xy[1]][xy[0] - 1] = '*'
			g[xy[3]][xy[2] - 1] = '*'
	elif xy[1] == xy[3]:
		try:
			g[xy[1] + 1][xy[0]] = '*'
			g[xy[1] + 1][xy[2]] = '*'
		except IndexError:
			g[xy[1] - 1][xy[0]] = '*'
			g[xy[1] - 1][xy[2]] = '*'
	else:
		g[xy[1]][xy[2]] = '*'
		g[xy[3]][xy[0]] = '*'
	for i in range(n):
		print(''.join(g[i]))


t = int(input())
for i in range(t):
	n = int(input())
	l = []
	r = []
	c = []
	for i in range(n):
		l1 = list(input())
		l.append(l1)
	for i in range(n):
		for j in range(n):
			if l[i][j] == '*':
				r.append(i)
				c.append(j)
	if r[0] == r[1]:
		if r[0] == n - 1:
			l[n - 2][c[0]] = '*'
			l[n - 2][c[1]] = '*'
		else:
			l[r[0] + 1][c[0]] = '*'
			l[r[0] + 1][c[1]] = '*'
	elif c[0] == c[1]:
		if c[0] == n - 1:
			l[r[0]][n - 2] = '*'
			l[r[1]][n - 2] = '*'
		else:
			l[r[0]][c[0] + 1] = '*'
			l[r[1]][c[1] + 1] = '*'
	else:
		l[r[0]][c[1]] = '*'
		l[r[1]][c[0]] = '*'
	for i in range(n):
		for j in range(n):
			print(l[i][j], end='')
		print()


import sys
sys.setrecursionlimit(10 ** 6)

def main(t):
	n = int(input())
	matrix = []
	row = 0
	track = []
	for i in range(n):
		col = 0
		k = input()
		for i in k:
			if i == '*':
				track.append(row)
				track.append(col)
			col += 1
		row += 1
		matrix.append(k)
	(r1, c1, r2, c2) = track
	if r1 == r2:
		if r1 + 1 < n:
			matrix[r1 + 1] = matrix[r1]
		else:
			matrix[r1 - 1] = matrix[r1]
	elif c1 == c2:
		if c1 + 1 < n:
			k = matrix[r1][:c1 + 1] + '*' + matrix[r1][c1 + 2:]
		else:
			k = matrix[r1][:c1 - 1] + '*' + matrix[r1][c1:]
		matrix[r1] = matrix[r2] = k
	else:
		matrix[r1] = matrix[r1][:c2] + '*' + matrix[r1][c2 + 1:]
		matrix[r2] = matrix[r1][:c1] + '*' + matrix[r1][c1 + 1:]
	print(*matrix, sep='\n')
	if t > 1:
		main(t - 1)
main(int(input()))


import os
import sys
from io import BytesIO, IOBase
import threading
from bisect import bisect_right
from math import gcd, log
from collections import Counter
from pprint import pprint
from itertools import permutations
from bisect import bisect_right
import heapq

def main():
	n = int(input())
	grid = []
	pos = []
	for i in range(n):
		grid.append([c for c in input()])
		for j in range(n):
			if grid[i][j] == '*':
				pos.append((i, j))
	if pos[0][0] == pos[1][0]:
		r = pos[0][0]
		grid[(r + 1) % n][pos[0][1]] = '*'
		grid[(r + 1) % n][pos[1][1]] = '*'
	elif pos[0][1] == pos[1][1]:
		r = pos[0][1]
		grid[pos[0][0]][(r + 1) % n] = '*'
		grid[pos[1][0]][(r + 1) % n] = '*'
	else:
		grid[pos[0][0]][pos[1][1]] = '*'
		grid[pos[1][0]][pos[0][1]] = '*'
	for li in grid:
		print(''.join(li))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	main()


import os
import collections
import itertools
from io import BytesIO, IOBase
import sys
import math
import bisect
from sys import stdin, stdout
from math import floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
sys.setrecursionlimit(100000000)
inp = lambda : int(input())
strng = lambda : input().strip()
jn = lambda x, l: x.join(map(str, l))
strl = lambda : list(input().strip())
mul = lambda : map(int, input().strip().split())
mulf = lambda : map(float, input().strip().split())
seq = lambda : list(map(int, input().strip().split()))
ceil = lambda x: int(x) if x == int(x) else int(x) + 1
ceildiv = lambda x, d: x // d if x % d == 0 else x // d + 1
flush = lambda : stdout.flush()
stdstr = lambda : stdin.readline()
stdint = lambda : int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
mod = 1000000007

def scanf(datatype=str):
	if datatype is not None:
		return datatype(sys.stdin.readline())
	else:
		return sys.stdin.readline()

def printf(answer):
	return sys.stdin.write(str(answer) + '\n')

def map_input(datatype):
	return map(datatype, sys.stdin.readline().split())

def list_input(datatype):
	return list(map(datatype, sys.stdin.readline().split()))

def testcase(number: int, solve_function):
	while number != 0:
		solve_function()
		number -= 1

def gcd(num1: int, num2: int):
	if num1 == 0:
		return num2
	if num2 == 0:
		return num1
	if num1 > num2:
		return gcd(num1 % num2, num2)
	else:
		return gcd(num1, num2 % num1)

def lcm(num1: int, num2: int):
	return num1 * num2 // gcd(num1, num2)

def big_power(num1: int, num2: int):
	result = 1
	while num2 > 0:
		if num2 & 1:
			result = result * num1
		num1 = num1 ** 2
		num2 >>= 1
	return result

def sieve_of_eratosthenes(number: int):
	num1 = (number - 1) // 2
	arr = [True] * num1
	(num2, num3, primes) = (0, 3, [2])
	while num3 * num3 < number:
		if arr[num2]:
			primes.append(num3)
			num4 = 2 * num2 * num2 + 6 * num2 + 3
			while num4 < num1:
				arr[num4] = False
				num4 = num4 + 2 * num2 + 3
		num2 += 1
		num3 += 1
	while num2 < num1:
		if arr[num2]:
			primes.append(num3)
		num2 += 1
		num3 += 2
	return primes

def dfs(graph, start, visited=None):
	if visited is None:
		visited = set()
	visited.add(start)
	for next in graph[start] - visited:
		dfs(graph, next, visited)
	return visited

def dfs_paths(graph, start, goal):
	stack = [(start, [start])]
	while stack:
		(vertex, path) = stack.pop()
		for next in graph[vertex] - set(path):
			if next == goal:
				yield (path + [next])
			else:
				stack.append((next, path + [next]))
	return stack

def bfs(graph, start):
	(visited, queue) = (set(), [start])
	while queue:
		vertex = queue.pop(0)
		if vertex not in visited:
			visited.add(vertex)
			queue.extend(graph[vertex] - visited)
	return visited

def bfs_paths(graph, start, goal):
	queue = [(start, [start])]
	while queue:
		(vertex, path) = queue.pop(0)
		for next in graph[vertex] - set(path):
			if next == goal:
				yield (path + [next])
			else:
				queue.append((next, path + [next]))
	return queue
from os import path
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
a = inp()

def func(n, data):
	loc = []
	to_add = []
	for j in range(n):
		for k in range(n):
			if data[j][k] == '*':
				loc.append(j)
				loc.append(k)
	if loc[0] == loc[2]:
		if loc[0] == n - 1:
			to_add.append([0, loc[1]])
			to_add.append([0, loc[3]])
		else:
			to_add.append([n - 1, loc[1]])
			to_add.append([n - 1, loc[3]])
	elif loc[1] == loc[3]:
		if loc[1] == n - 1:
			to_add.append([loc[0], 0])
			to_add.append([loc[2], 0])
		else:
			to_add.append([loc[0], n - 1])
			to_add.append([loc[2], n - 1])
	else:
		to_add.append([loc[2], loc[1]])
		to_add.append([loc[0], loc[3]])
	for j in range(n):
		for k in range(n):
			if [j, k] in to_add:
				data[j][k] = '*'
			print(data[j][k], end='')
		print('')
for i in range(a):
	n = inp()
	data = []
	for i in range(n):
		data.append(list(input()))
	func(n, data)


for _ in range(int(input())):
	n = int(input())
	g = [list(input()) for _ in range(n)]
	(r1, c1, r2, c2) = (-1, -1, -1, -1)
	for i in range(n):
		for j in range(n):
			if g[i][j] == '*':
				if r1 < 0:
					(r1, c1) = (i, j)
				else:
					(r2, c2) = (i, j)
	if r1 == r2:
		r = (r1 + 1) % n
		g[r][c1] = g[r][c2] = '*'
	elif c1 == c2:
		c = (c1 + 1) % n
		g[r1][c] = g[r2][c] = '*'
	else:
		g[min(r1, r2)][min(c1, c2)] = g[min(r1, r2)][max(c1, c2)] = g[max(r1, r2)][min(c1, c2)] = g[max(r1, r2)][max(c1, c2)] = '*'
	for v in g:
		print(''.join(v))


t = int(input())
for z in range(t):
	n = int(input())
	arr = []
	for i in range(n):
		field = input()
		arr.append(list(field))
	posi = []
	for y in range(n):
		for x in range(n):
			if arr[y][x] == '*':
				posi.append([x, y])
	if posi[0][0] != posi[1][0] and posi[0][1] != posi[1][1]:
		arr[posi[1][1]][posi[0][0]] = '*'
		arr[posi[0][1]][posi[1][0]] = '*'
	elif posi[0][0] == posi[1][0] and posi[0][1] != posi[1][1]:
		if posi[0][0] == n - 1:
			arr[posi[0][1]][posi[0][0] - 1] = '*'
			arr[posi[1][1]][posi[1][0] - 1] = '*'
		else:
			arr[posi[0][1]][posi[0][0] + 1] = '*'
			arr[posi[1][1]][posi[1][0] + 1] = '*'
	elif posi[0][1] == n - 1:
		arr[posi[0][1] - 1][posi[0][0]] = '*'
		arr[posi[1][1] - 1][posi[1][0]] = '*'
	else:
		arr[posi[0][1] + 1][posi[0][0]] = '*'
		arr[posi[1][1] + 1][posi[1][0]] = '*'
	for i in range(n):
		print(''.join(arr[i]))


for _ in range(int(input())):
	k = int(input())
	l = []
	for i in range(k):
		l.append(list(input()))
	index = []
	for i in range(k):
		for j in range(k):
			if l[i][j] == '*':
				index.append([i, j])
	if index[0][0] == index[1][0]:
		if index[0][0] == k - 1:
			l[-2][index[0][1]] = '*'
			l[-2][index[1][1]] = '*'
		else:
			l[index[0][0] + 1][index[0][1]] = '*'
			l[index[0][0] + 1][index[1][1]] = '*'
	elif index[0][1] == index[1][1]:
		if index[0][1] == k - 1:
			l[index[0][0]][-2] = '*'
			l[index[1][0]][-2] = '*'
		else:
			l[index[0][0]][index[0][1] + 1] = '*'
			l[index[1][0]][index[1][1] + 1] = '*'
	else:
		l[index[0][0]][index[1][1]] = '*'
		l[index[1][0]][index[0][1]] = '*'
	for i in l:
		for j in i:
			print(j, end='')
		print()


for t in range(int(input())):
	n = int(input())
	data = []
	for i in range(n):
		l = input()
		for j in range(n):
			if l[j] == '*':
				data.append([i, j])
	(f, s) = data
	if f[0] != s[0] and f[1] != s[1]:
		t = [f[0], s[1]]
		fo = [s[0], f[1]]
		data.append(t)
		data.append(fo)
	elif f[0] == s[0]:
		if f[0] + 1 < n:
			t = [f[0] + 1, f[1]]
			fo = [s[0] + 1, s[1]]
		else:
			t = [f[0] - 1, f[1]]
			fo = [s[0] - 1, s[1]]
		data.append(t)
		data.append(fo)
	else:
		if f[1] + 1 < n:
			t = [f[0], f[1] + 1]
			fo = [s[0], s[1] + 1]
		else:
			t = [f[0], f[1] - 1]
			fo = [s[0], s[1] - 1]
		data.append(t)
		data.append(fo)
	for i in range(n):
		for j in range(n):
			if [i, j] in data:
				print('*', end='')
			else:
				print('.', end='')
		print()


t = int(input())
for _ in range(t):
	n = int(input())
	pos = []
	m = []
	count = 0
	for i in range(n):
		a = input()
		if count != 2:
			for j in range(n):
				if a[j] == '*':
					pos.append((i, j))
					count += 1
		m.append(a)
	r1 = pos[0][0]
	c1 = pos[0][1]
	r2 = pos[1][0]
	c2 = pos[1][1]
	if r1 == r2:
		if r1 + 1 < n:
			r = r1 + 1
		else:
			r = r1 - 1
		if c1 < c2:
			m[r] = m[r][0:c1] + '*' + m[r][c1 + 1:c2] + '*' + m[r][c2 + 1:]
		else:
			m[r] = m[r][0:c2] + '*' + m[r][c2 + 1:c1] + '*' + m[r][c1 + 1:]
	elif c1 == c2:
		if c1 + 1 < n:
			c = c1 + 1
		else:
			c = c1 - 1
		m[r1] = m[r1][0:c] + '*' + m[r1][c + 1:]
		m[r2] = m[r2][0:c] + '*' + m[r2][c + 1:]
	else:
		m[r1] = m[r1][0:c2] + '*' + m[r1][c2 + 1:]
		m[r2] = m[r2][0:c1] + '*' + m[r2][c1 + 1:]
	for i in range(n):
		print(m[i])


t = int(input())
for _ in range(t):
	n = int(input())
	pos_r = []
	pos_c = []
	rows = []
	for i in range(n):
		rows.append(list(input()))
		for (j, c) in enumerate(rows[-1]):
			if c == '*':
				pos_r.append(i)
				pos_c.append(j)
	if pos_r[0] == pos_r[1]:
		r = (pos_r[0] + 1) % n
		for c in pos_c:
			rows[r][c] = '*'
	elif pos_c[0] == pos_c[1]:
		c = (pos_c[0] + 1) % n
		for r in pos_r:
			rows[r][c] = '*'
	else:
		for (r, c) in zip(pos_r[::-1], pos_c):
			rows[r][c] = '*'
	rows = '\n'.join((''.join(row) for row in rows))
	print(rows)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	a = []
	for i in range(n):
		a.append(input())
	x = []
	y = []
	for i in range(n):
		for j in range(n):
			if a[i][j] == '*':
				x.append(i)
				y.append(j)
	if x[0] == x[1]:
		i = 0
		while i == x[0]:
			i += 1
		mi = min(y[0], y[1])
		ma = max(y[0], y[1])
		a[i] = a[i][0:mi] + '*' + a[i][mi + 1:ma] + '*' + a[i][ma + 1:]
	elif y[0] == y[1]:
		j = 0
		while j == y[0]:
			j += 1
		a[x[0]] = a[x[0]][:j] + '*' + a[x[0]][j + 1:]
		a[x[1]] = a[x[1]][:j] + '*' + a[x[1]][j + 1:]
	else:
		a[x[0]] = a[x[0]][:y[1]] + '*' + a[x[0]][y[1] + 1:]
		a[x[1]] = a[x[1]][:y[0]] + '*' + a[x[1]][y[0] + 1:]
	for i in range(n):
		print(a[i])


for _ in range(int(input())):
	n = int(input())
	s = [list(input().strip()) for i in range(n)]
	cand = []
	for i in range(n):
		for j in range(n):
			if s[i][j] == '*':
				cand.append([i, j])
	if cand[0][0] != cand[1][0] and cand[0][1] != cand[1][1]:
		s[cand[1][0]][cand[0][1]] = '*'
		s[cand[0][0]][cand[1][1]] = '*'
	elif cand[0][0] == cand[1][0]:
		if 0 <= cand[0][0] + 1 < n:
			s[cand[0][0] + 1][cand[0][1]] = '*'
			s[cand[1][0] + 1][cand[1][1]] = '*'
		else:
			s[cand[0][0] - 1][cand[0][1]] = '*'
			s[cand[1][0] - 1][cand[1][1]] = '*'
	elif cand[0][1] == cand[1][1]:
		if 0 <= cand[0][1] + 1 < n:
			s[cand[0][0]][cand[0][1] + 1] = '*'
			s[cand[1][0]][cand[0][1] + 1] = '*'
		else:
			s[cand[0][0]][cand[0][1] - 1] = '*'
			s[cand[1][0]][cand[0][1] - 1] = '*'
	for i in s:
		print(''.join(i))


for _ in range(int(input())):
	n = int(input())
	l = []
	r1 = -1
	c1 = -1
	c2 = -1
	r2 = -1
	for i in range(n):
		s = input()
		for j in range(n):
			if s[j] == '*':
				if r1 == -1:
					r1 = i
					c1 = j
				else:
					r2 = i
					c2 = j
		l.append(list(s))
	if c1 == c2:
		if c1 == n - 1:
			l[r1][0] = '*'
			l[r2][0] = '*'
		else:
			l[r1][-1] = '*'
			l[r2][-1] = '*'
	elif r1 == r2:
		if r1 == n - 1:
			l[0][c1] = '*'
			l[0][c2] = '*'
		else:
			l[-1][c1] = '*'
			l[-1][c2] = '*'
	else:
		l[r2][c1] = '*'
		l[r1][c2] = '*'
	for i in l:
		print(''.join(i))


t = int(input())
for _ in range(t):
	n = int(input())
	field = [[0] for _ in range(n)]
	dots = [[0, 0], [0, 0]]
	di = 0
	for i in range(n):
		field[i] = list(input())
		for j in range(n):
			if '*' == field[i][j]:
				dots[di] = (i, j)
				di += 1
	if dots[0][0] != dots[1][0] and dots[0][1] != dots[1][1]:
		field[dots[0][0]][dots[1][1]] = '*'
		field[dots[1][0]][dots[0][1]] = '*'
	elif dots[0][0] == dots[1][0]:
		if dots[0][0] != n - 1:
			field[dots[0][0] + 1][dots[0][1]] = '*'
			field[dots[1][0] + 1][dots[1][1]] = '*'
		else:
			field[dots[0][0] - 1][dots[0][1]] = '*'
			field[dots[0][0] - 1][dots[1][1]] = '*'
	elif dots[0][1] == dots[1][1]:
		if dots[0][1] != n - 1:
			field[dots[0][0]][dots[0][1] + 1] = '*'
			field[dots[1][0]][dots[1][1] + 1] = '*'
		else:
			field[dots[0][0]][dots[0][1] - 1] = '*'
			field[dots[1][0]][dots[1][1] - 1] = '*'
	for i in range(n):
		print(''.join(field[i]))


for _ in range(int(input())):
	n = int(input())
	a = []
	s1 = []
	s2 = []
	for i in range(n):
		x = input()
		for (z, j) in enumerate(x):
			if j == '*':
				if not s1:
					s1 = [i, z]
				else:
					s2 = [i, z]
		a.append(list(x))
	if s1[0] == s2[0]:
		a[(s1[0] + 1) % n][s1[1]] = '*'
		a[(s1[0] + 1) % n][s2[1]] = '*'
	elif s1[1] == s2[1]:
		a[s1[0]][(s1[1] + 1) % n] = '*'
		a[s2[0]][(s2[1] + 1) % n] = '*'
	else:
		a[s1[0]][s2[1]] = '*'
		a[s2[0]][s1[1]] = '*'
	for i in a:
		print(''.join(i))


for _ in range(int(input())):
	n = int(input())
	t = []
	mat = []
	for k in range(n):
		row = [i for i in input()]
		mat.append(row)
	for i in range(n):
		for j in range(n):
			if mat[i][j] == '*':
				t.append((i, j))
	x = t[0]
	y = t[1]
	new = []
	if x[0] == y[0]:
		if x[0] == n - 1:
			new.append((x[0] - 1, x[1]))
			new.append((y[0] - 1, y[1]))
		else:
			new.append((x[0] + 1, x[1]))
			new.append((y[0] + 1, y[1]))
	elif x[1] == y[1]:
		if x[1] == n - 1:
			new.append((x[0], x[1] - 1))
			new.append((y[0], y[1] - 1))
		else:
			new.append((x[0], x[1] + 1))
			new.append((y[0], y[1] + 1))
	else:
		new.append((x[0], y[1]))
		new.append((y[0], x[1]))
	mat[new[0][0]][new[0][1]] = '*'
	mat[new[1][0]][new[1][1]] = '*'
	for row in mat:
		print(''.join(row))


for _ in range(int(input())):
	n = int(input())
	coord = list()
	for i in range(n):
		s = input()
		try:
			idx1 = s.index('*')
			coord.append([i, idx1])
			try:
				idx2 = s.index('*', idx1 + 1)
				coord.append([i, idx2])
			except ValueError:
				continue
		except ValueError:
			continue
	mn_row = min(coord[0][0], coord[1][0])
	y = abs(coord[0][0] - coord[1][0])
	if y == 0:
		y = 1
		if mn_row == n - 1:
			mn_row = n - 2
	mn_col = min(coord[0][1], coord[1][1])
	x = abs(coord[0][1] - coord[1][1])
	if x == 0:
		x = 1
		if mn_col == n - 1:
			mn_col = n - 2
	output = []
	for i in range(n):
		output.append(['.'] * n)
	output[mn_row][mn_col] = '*'
	output[mn_row + y][mn_col] = '*'
	output[mn_row][mn_col + x] = '*'
	output[mn_row + y][mn_col + x] = '*'
	print('\n'.join((''.join(output[r]) for r in range(n))))


for _ in range(int(input())):
	n = int(input())
	l = []
	for i in range(n):
		e = input()
		l.append(list(e))
	ans = []
	for i in range(n):
		for j in range(n):
			if l[i][j] == '*':
				ans.append([i, j])
	(x1, y1) = (ans[0][0], ans[0][1])
	(x2, y2) = (ans[1][0], ans[1][1])
	if x1 == x2:
		if x1 + 1 < n:
			l[x1 + 1][y1] = '*'
			l[x2 + 1][y2] = '*'
		else:
			l[x1 - 1][y1] = '*'
			l[x2 - 1][y2] = '*'
	elif y1 == y2:
		if y1 + 1 < n:
			l[x1][y1 + 1] = '*'
			l[x2][y2 + 1] = '*'
		else:
			l[x1][y1 - 1] = '*'
			l[x2][y2 - 1] = '*'
	else:
		l[x1][y2] = '*'
		l[x2][y1] = '*'
	for k in l:
		print(''.join(k))


for _ in range(int(input())):
	n = int(input())
	graph = []
	data = []
	for i in range(n):
		tmp = list(input())
		graph.append(tmp)
		if '*' in tmp:
			for j in range(len(tmp)):
				if tmp[j] == '*':
					data.append((i, j))
	(x1, y1) = data[0]
	(x2, y2) = data[1]
	if x1 == x2:
		if x1 + 1 < n - 1:
			graph[x1 + 1][y1] = '*'
			graph[x2 + 1][y2] = '*'
		else:
			graph[x1 - 1][y1] = '*'
			graph[x2 - 1][y2] = '*'
	elif y1 == y2:
		if y1 + 1 < n - 1:
			graph[x1][y1 + 1] = '*'
			graph[x2][y2 + 1] = '*'
		else:
			graph[x1][y1 - 1] = '*'
			graph[x2][y2 - 1] = '*'
	else:
		graph[min(x1, x2)][min(y1, y2)] = '*'
		graph[max(x1, x2)][min(y1, y2)] = '*'
		graph[min(x1, x2)][max(y1, y2)] = '*'
		graph[max(x1, x2)][max(y1, y2)] = '*'
	for line in graph:
		print(''.join(line))


for _ in range(int(input())):
	n = int(input())
	arr = []
	for _ in range(n):
		arr.append([w for w in input()])
	p = []
	for i in range(n):
		for j in range(n):
			if arr[i][j] == '*':
				p.append([i, j])
	if p[0][0] == p[1][0] or p[0][1] == p[1][1]:
		if p[0][0] == p[1][0]:
			try:
				arr[p[0][0] + 1][p[0][1]] = '*'
				arr[p[0][0] + 1][p[1][1]] = '*'
			except:
				arr[p[0][0] - 1][p[0][1]] = '*'
				arr[p[0][0] - 1][p[1][1]] = '*'
		else:
			try:
				arr[p[0][0]][p[0][1] + 1] = '*'
				arr[p[1][0]][p[0][1] + 1] = '*'
			except:
				arr[p[0][0]][p[0][1] - 1] = '*'
				arr[p[1][0]][p[0][1] - 1] = '*'
	else:
		arr[p[0][0]][p[1][1]] = '*'
		arr[p[1][0]][p[0][1]] = '*'
	for item in arr:
		for w in item:
			print(w, end='')
		print('')


from sys import stdin
t = int(stdin.readline().strip())
for i in range(t):
	n = int(stdin.readline().strip())
	a = [[-1, -1], [-1, -1]]
	for k in range(n):
		line = stdin.readline().strip()
		for char in range(len(line)):
			if line[char] == '*':
				if a[0][0] == -1:
					a[0] = [k, char]
				else:
					a[1] = [k, char]
	if a[0][0] == a[1][0]:
		if a[0][0] == 0:
			a[0][0] = 1
		else:
			a[0][0] = 0
	elif a[0][1] == a[1][1]:
		if a[0][1] == 0:
			a[0][1] = 1
		else:
			a[0][1] = 0
	d = [a[0][0], a[1][0]]
	e = [a[0][1], a[1][1]]
	for l in range(n):
		g = '.' * n
		if l in d:
			g = list('.' * n)
			g[e[0]] = '*'
			g[e[1]] = '*'
			g = ''.join(g)
		print(g)


for _ in range(int(input())):
	n = int(input())
	l = []
	flag = False
	lst = set()
	list_i = []
	for _ in range(n):
		s = input()
		lst.add(s.find('*'))
		lst.add(s.rfind('*'))
		if s.count('*') == 2:
			list_i.append(s)
			flag = True
		l.append(s)
	if -1 in lst:
		lst.remove(-1)
	lst = list(lst)
	if len(lst) == 1:
		if lst[0] == 0:
			lst.append(1)
		else:
			lst.append(0)
	m = 2
	if flag:
		if l[0].count('*') > 0:
			m = 0
		elif l[-1].count('*') > 0:
			m = 1
		if m == 0:
			print(l[0])
			print(l[0])
			for i in l[2:]:
				print(i)
		elif m == 1:
			for i in l[0:-2]:
				print(i)
			print(l[-1])
			print(l[-1])
		else:
			print(list_i[0])
			for i in l[1:]:
				print(i)
	else:
		for i in l:
			if i.count('*') > 0:
				for j in range(len(i)):
					if j in lst:
						print('*', end='')
					else:
						print('.', end='')
				print()
			else:
				print(i)


for i in range(int(input())):
	a = int(input())
	blanck = []
	pos = []
	for j in range(a):
		lst = list(input())
		for k in range(len(lst)):
			if lst[k] == '*':
				pos.append((j, k))
		blanck.append(lst)
	arr = blanck
	(x, y) = ([], [])
	if pos == []:
		arr[0][0] = '*'
		arr[0][1] = '*'
		arr[1][1] = '*'
		arr[1][0] = '*'
	try:
		if pos:
			for i in pos:
				x.append(i[0])
				y.append(i[1])
			if len(set(x)) == 1:
				if x[0] + 1 < len(arr):
					x.append(x[0] + 1)
				elif x[0] - 1 >= 0:
					x.append(x[0] - 1)
			if len(set(y)) == 1:
				if y[0] + 1 < len(arr):
					y.append(y[0] + 1)
				elif y[0] - 1 >= 0:
					y.append(y[0] - 1)
			for i in x:
				for j in y:
					arr[i][j] = '*'
	except:
		pass
	for i in arr:
		print(''.join(i))


for i in range(int(input())):
	L = []
	n = int(input())
	m = [['.'] * n for i in range(n)]
	x = []
	y = []
	for j in range(n):
		s = input()
		for k in range(len(s)):
			if s[k] == '*':
				m[j][k] = '*'
				x.append(j)
				y.append(k)
	if len(set(x)) == 1:
		if x[0] != 0:
			m[0][y[0]] = '*'
			m[0][y[1]] = '*'
		else:
			m[1][y[0]] = '*'
			m[1][y[1]] = '*'
	elif len(set(y)) == 1:
		if y[0] != 0:
			m[x[0]][0] = '*'
			m[x[1]][0] = '*'
		else:
			m[x[0]][1] = '*'
			m[x[1]][1] = '*'
	else:
		m[x[0]][y[1]] = '*'
		m[x[1]][y[0]] = '*'
	for ll in m:
		print(''.join(ll))


t = int(input())
for p in range(t):
	n = int(input())
	lst = []
	for i in range(n):
		lst1 = list(input())
		lst.append(lst1)
	lst2 = []
	for i in range(n):
		for j in range(n):
			if lst[i][j] == '*':
				lst2.append(i)
				lst2.append(j)
	if lst2[0] == lst2[2]:
		if lst2[0] != lst2[3]:
			lst[lst2[3]][lst2[1]] = '*'
			lst[lst2[3]][lst2[3]] = '*'
		else:
			lst[lst2[1]][lst2[1]] = '*'
			lst[lst2[1]][lst2[3]] = '*'
	elif lst2[1] == lst2[3]:
		if lst2[1] != lst2[2]:
			lst[lst2[0]][lst2[2]] = '*'
			lst[lst2[2]][lst2[2]] = '*'
		else:
			lst[lst2[0]][lst2[0]] = '*'
			lst[lst2[2]][lst2[0]] = '*'
	else:
		lst[lst2[0]][lst2[3]] = '*'
		lst[lst2[2]][lst2[1]] = '*'
	for i in lst:
		print(*i, sep='')


mas = list(map(int, input().split()))
t = mas[0]
for j in range(t):
	mas = list(map(int, input().split()))
	n = mas[0]
	lst = []
	res = []
	for k in range(n):
		mas = list(map(str, input().split()))
		mas = mas[0]
		lst = lst + [list(mas)]
		ind = mas.find('*')
		while ind > -1:
			res = res + [[k, ind]]
			ind = mas.find('*', ind + 1)
	if res[0][0] != res[1][0] and res[0][1] != res[1][1]:
		res = res + [[res[0][0], res[1][1]]] + [[res[1][0], res[0][1]]]
	elif res[0][0] != res[1][0]:
		if res[0][1] == n - 1:
			res = res + [[res[0][0], res[0][1] - 1]] + [[res[1][0], res[0][1] - 1]]
		else:
			res = res + [[res[0][0], res[0][1] + 1]] + [[res[1][0], res[0][1] + 1]]
	elif res[0][1] != res[1][1]:
		if res[0][0] == n - 1:
			res = res + [[res[0][0] - 1, res[0][1]]] + [[res[0][0] - 1, res[1][1]]]
		else:
			res = res + [[res[0][0] + 1, res[0][1]]] + [[res[0][0] + 1, res[1][1]]]
	for k in range(4):
		lst[res[k][0]][res[k][1]] = '*'
	for k in range(n):
		print(''.join(lst[k]))


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		l = []
		for i in range(n):
			arr = list(input())
			l.append(arr)
		ans = []
		for i in range(n):
			for j in range(n):
				if l[i][j] == '*':
					ans.append([i, j])
		if ans[0][0] == ans[1][0]:
			if ans[0][0] == 0:
				l[1][ans[0][1]] = '*'
				l[1][ans[1][1]] = '*'
			else:
				l[0][ans[0][1]] = '*'
				l[0][ans[1][1]] = '*'
		elif ans[0][1] == ans[1][1]:
			if ans[0][1] == 0:
				l[ans[0][0]][1] = '*'
				l[ans[1][0]][1] = '*'
			else:
				l[ans[0][0]][0] = '*'
				l[ans[1][0]][0] = '*'
		else:
			l[ans[0][0]][ans[1][1]] = '*'
			l[ans[1][0]][ans[0][1]] = '*'
		for i in range(n):
			for j in range(n):
				print(l[i][j], end='')
			print()
main()


for i in range(int(input())):
	n = int(input())
	array = []
	I = []
	for i in range(1, 10):
		continue
	for j in range(1, 10):
		continue
	for i in range(n):
		temp = list(input())
		if '*' in temp:
			I.append(temp.index('*'))
		array.append(temp)
	for i in range(len(array)):
		if '*' in array[i]:
			if len(I) == 1:
				if i == 0:
					array[n - 1] = array[i]
				else:
					array[0] = array[i]
				break
			if I[0] == I[1]:
				if I[0] != n - 1:
					I[0] = n - 1
				else:
					I[0] = 0
			array[i][I[1]] = '*'
			array[i][I[0]] = '*'
	for i in range(1, 10):
		continue
	for i in array:
		print(''.join(map(str, i)))


test_case = int(input())
for i in range(test_case):
	n = int(input())
	matrix = []
	for j in range(n):
		matrix.append(list(input()))
	found1 = False
	found2 = False
	for j in range(n):
		if matrix[j].__contains__('*') and found1 == False:
			pos1 = [j, matrix[j].index('*')]
			matrix[pos1[0]][pos1[1]] = '.'
			found1 = True
		if matrix[j].__contains__('*') and found1 == True:
			pos2 = [j, matrix[j].index('*')]
			found2 = True
		if found1 and found2:
			break
	matrix[pos1[0]][pos1[1]] = '*'
	if pos1[0] == pos2[0]:
		if pos2[0] < n - 1:
			pos3 = [pos1[0] + 1, pos1[1]]
			pos4 = [pos2[0] + 1, pos2[1]]
		else:
			pos3 = [pos1[0] - 1, pos1[1]]
			pos4 = [pos2[0] - 1, pos2[1]]
	elif pos1[1] == pos2[1]:
		pos3 = [pos1[0], abs(pos1[1] - 1)]
		pos4 = [pos2[0], abs(pos2[1] - 1)]
	else:
		pos3 = [pos1[0], pos2[1]]
		pos4 = [pos2[0], pos1[1]]
	matrix[pos3[0]][pos3[1]] = '*'
	matrix[pos4[0]][pos4[1]] = '*'
	for j in range(n):
		str = ''
		print(str.join(matrix[j]))


t = int(input())
for i in range(t):
	n = int(input())
	a = [[str(n) for n in input()] for i in range(n)]
	x = []
	y = []
	for i in range(n):
		for j in range(n):
			if a[i][j] == '*':
				x.append(i)
				y.append(j)
	if a[x[0]][y[1]] != '*' and a[x[1]][y[0]] != '*':
		a[x[0]][y[1]] = '*'
		a[x[1]][y[0]] = '*'
	else:
		if y[0] != y[1]:
			if x[0] != 0:
				a[0][y[1]] = '*'
				a[0][y[0]] = '*'
			else:
				a[n - 1][y[1]] = '*'
				a[n - 1][y[0]] = '*'
		if x[0] != x[1]:
			if y[0] != 0:
				a[x[1]][0] = '*'
				a[x[0]][0] = '*'
			else:
				a[x[1]][n - 1] = '*'
				a[x[0]][n - 1] = '*'
	for i in a:
		print(*i, sep='')


for _ in range(int(input())):
	n = int(input())
	s = []
	for i in range(n):
		s.append(list(input()))
	stars = []
	for i in range(n):
		for j in range(n):
			if s[i][j] == '*':
				stars.append([i, j])
	r1 = stars[0][0]
	r2 = stars[1][0]
	c1 = stars[0][1]
	c2 = stars[1][1]
	if r1 == r2:
		if r1 == n - 1:
			s[r1 - 1][c1] = '*'
			s[r2 - 1][c2] = '*'
		else:
			s[stars[0][0] + 1][c1] = '*'
			s[r2 + 1][c2] = '*'
	elif c1 == c2:
		if c1 == n - 1:
			s[r1][c1 - 1] = '*'
			s[r2][c2 - 1] = '*'
		else:
			s[stars[0][0]][c1 + 1] = '*'
			s[r2][c2 + 1] = '*'
	else:
		s[r1][c2] = '*'
		s[r2][c1] = '*'
	for i in range(n):
		for j in range(n):
			print(s[i][j], end='')
		print()


def gen(lr, i, j):
	lr[i] = lr[i][:j] + '*' + lr[i][j + 1:]

def gen2(lr, i, j1, j2):
	lr[i] = lr[i][:j1] + '*' + lr[i][j1 + 1:j2] + '*' + lr[i][j2 + 1:]
t = int(input())
for x in range(t):
	n = int(input())
	lst = []
	i = []
	j = []
	for k in range(n):
		l = input()
		if '*' in l:
			if l.count('*') == 2:
				sd = -1
				while l[sd] != '*':
					sd -= 1
				j.append(l.index('*'))
				i.append(k)
				j.append(sd + len(l))
				i.append(k)
			else:
				j.append(l.index('*'))
				i.append(k)
		lst.append(l)
	if i[0] == i[1]:
		if i[0] == 0:
			i.append(1)
			i.append(1)
			j.append(j[0])
			j.append(j[1])
		else:
			i.append(i[0] - 1)
			i.append(i[0] - 1)
			j.append(j[0])
			j.append(j[1])
	elif j[0] == j[1]:
		if j[0] == 0:
			j.append(1)
			j.append(1)
			i.append(i[0])
			i.append(i[1])
		else:
			j.append(j[0] - 1)
			j.append(j[0] - 1)
			i.append(i[0])
			i.append(i[1])
	else:
		i.append(i[1])
		i.append(i[0])
		j.append(j[0])
		j.append(j[1])
	if i[-1] != i[-2]:
		for hj in range(2):
			gen(lst, i[hj + 2], j[hj + 2])
	else:
		gen2(lst, i[-1], j[2], j[3])
	for jk in lst:
		print(jk)


test = int(input())
while test > 0:
	n = int(input())
	arr = []
	for i in range(n):
		arr.append(list(input()))
	x = y = 0
	x1 = y1 = 0
	count = 1
	for i in range(n):
		for j in range(n):
			if count == 1 and arr[i][j] == '*':
				x = j
				y = i
				count += 1
			elif count == 2 and arr[i][j] == '*':
				x1 = j
				y1 = i
				break
	if y == y1:
		arr[(y + 1) % n][x1] = '*'
		arr[(y + 1) % n][x] = '*'
	elif x1 == x:
		arr[y1][(x1 + 1) % n] = '*'
		arr[y][(x + 1) % n] = '*'
	else:
		arr[y][x1] = '*'
		arr[y1][x] = '*'
	for s1 in arr:
		s = ''
		for a in s1:
			s += str(a)
		print(s)
	test -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	a = []
	for i in range(n):
		a.append(list(input()))
	pos = []
	for i in range(n):
		for j in range(n):
			if a[i][j] == '*':
				pos.append([i, j])
	if pos[0][0] != pos[1][0] and pos[0][1] != pos[1][1]:
		a[pos[0][0]][pos[1][1]] = '*'
		a[pos[1][0]][pos[0][1]] = '*'
	elif pos[0][0] == pos[1][0]:
		if pos[0][0] < n - 1:
			a[pos[0][0] + 1][pos[0][1]] = '*'
			a[pos[1][0] + 1][pos[1][1]] = '*'
		else:
			a[pos[0][0] - 1][pos[0][1]] = '*'
			a[pos[1][0] - 1][pos[1][1]] = '*'
	elif pos[0][1] == pos[1][1]:
		if pos[0][1] < n - 1:
			a[pos[0][0]][pos[0][1] + 1] = '*'
			a[pos[1][0]][pos[1][1] + 1] = '*'
		else:
			a[pos[0][0]][pos[0][1] - 1] = '*'
			a[pos[1][0]][pos[1][1] - 1] = '*'
	for i in range(n):
		print(''.join(a[i]))


t = int(input())
while t:
	n = int(input())
	x = set()
	y = set()
	matrix = [list(input()) for _ in range(n)]
	for i in range(n):
		for j in range(n):
			if matrix[i][j] == '*':
				x.add(i)
				y.add(j)
	x = list(x)
	y = list(y)
	if len(x) == 1:
		if x[0] == n - 1:
			x.append(n - 2)
		else:
			x.append(x[0] + 1)
	if len(y) == 1:
		if y[0] == n - 1:
			y.append(n - 2)
		else:
			y.append(y[0] + 1)
	for i in range(len(x)):
		for j in range(len(y)):
			matrix[x[i]][y[j]] = '*'
	for i in range(len(matrix)):
		print(''.join(matrix[i]))
	t -= 1


for _ in range(int(input())):
	n = int(input())
	l = []
	for i in range(n):
		l.append(list(input()))
	col = []
	row = []
	for i in range(n):
		for j in range(n):
			if l[i][j] == '*':
				row.append(i)
				col.append(j)
	ansr = []
	ansc = []
	if row[0] == row[1]:
		if row[0] != n - 1:
			ansr.append(row[0] + 1)
			ansr.append(row[0] + 1)
		else:
			ansr.append(row[0] - 1)
			ansr.append(row[0] - 1)
		ansc = col
	elif col[0] == col[1]:
		if col[0] != n - 1:
			ansc.append(col[0] + 1)
			ansc.append(col[0] + 1)
		else:
			ansc.append(col[0] - 1)
			ansc.append(col[0] - 1)
		ansr = row
	else:
		ansr = [row[0], row[1]]
		ansc = [col[1], col[0]]
	l[ansr[0]][ansc[0]] = '*'
	l[ansr[1]][ansc[1]] = '*'
	for i in l:
		print(''.join(i))


import sys
rd = sys.stdin.readline
t = int(rd())
for _ in range(t):
	n = int(rd())
	a = [list(list(rd().strip())) for _ in range(n)]
	x = set()
	y = set()
	for i in range(n):
		for j in range(n):
			if a[i][j] == '*':
				x.add(i)
				y.add(j)
	if len(x) != 2:
		for i in range(n):
			if i not in x:
				x.add(i)
				break
	if len(y) != 2:
		for j in range(n):
			if j not in y:
				y.add(j)
				break
	for i in x:
		for j in y:
			a[i][j] = '*'
	for i in range(n):
		print(''.join(a[i]))


for q in range(int(input())):
	n = int(input())
	a = list()
	for i in range(n):
		a.append(list(input().strip()))
	(x1, y1, x2, y2) = (0, 0, 0, 0)
	p = True
	for i in range(n):
		for j in range(n):
			if a[i][j] == '*' and p:
				x1 = i
				y1 = j
				p = False
			elif a[i][j] == '*':
				x2 = i
				y2 = j
	if x1 == x2:
		if x1 != n - 1:
			a[x1 + 1][y1] = '*'
			a[x2 + 1][y2] = '*'
		else:
			a[x1 - 1][y1] = '*'
			a[x2 - 1][y2] = '*'
	elif y1 == y2:
		if y1 != n - 1:
			a[x1][y1 + 1] = '*'
			a[x2][y2 + 1] = '*'
		else:
			a[x1][y1 - 1] = '*'
			a[x2][y2 - 1] = '*'
	else:
		a[x1][y2] = '*'
		a[x2][y1] = '*'
	for i in a:
		for j in i:
			print(j, end='')
		print()


t = int(input())
for case in range(t):
	n = int(input())
	lads = []
	for i in range(n):
		lads.append(str(input()))
	x1 = -1
	x2 = -1
	y1 = -1
	y2 = -1
	for i in range(n):
		testst = lads[i]
		if x1 == -1:
			if '*' in testst:
				x1 = testst.index('*')
				y1 = i
				newtest = testst[0:testst.index('*')] + testst[testst.index('*') + 1:]
				if '*' in newtest:
					x2 = newtest.index('*') + 1
					y2 = i
		elif x2 == -1:
			if '*' in testst:
				x2 = testst.index('*')
				y2 = i
	outbox = []
	if x1 == x2:
		if x1 >= 1:
			x2 = 0
		else:
			x2 = x1 + 1
	if y1 == y2:
		if y1 >= 1:
			y2 = 0
		else:
			y2 = y1 + 1
	for i in range(n):
		outstr = ''
		if y1 == i or y2 == i:
			if x1 > x2:
				outstr = '.' * x2 + '*' + '.' * (x1 - x2 - 1) + '*' + '.' * (n - x1 - 1)
			if x2 > x1:
				outstr = '.' * x1 + '*' + '.' * (x2 - x1 - 1) + '*' + '.' * (n - x2 - 1)
		else:
			outstr = '.' * n
		print(outstr)


q = int(input())
for i in range(q):
	w = int(input())
	l = []
	for j in range(w):
		e = input()
		for k in range(w):
			if e[k] == '*':
				l.append([j, k])
	if l[0][0] != l[1][0] and l[0][1] != l[1][1]:
		l.append([l[0][0], l[1][1]])
		l.append([l[1][0], l[0][1]])
	elif l[0][0] == l[1][0] and l[0][1] != l[1][1]:
		if l[0][0] == 0:
			l.append([1, l[0][1]])
			l.append([1, l[1][1]])
		else:
			l.append([0, l[0][1]])
			l.append([0, l[1][1]])
	elif l[0][0] != l[1][0] and l[0][1] == l[1][1]:
		if l[0][1] == 0:
			l.append([l[0][0], 1])
			l.append([l[1][0], 1])
		else:
			l.append([l[0][0], 0])
			l.append([l[1][0], 0])
	for j in range(w):
		if j not in [l[0][0], l[1][0], l[2][0], l[3][0]]:
			print('.' * w)
		else:
			s = '.' * w
			for k in range(4):
				if l[k][0] == j:
					s = s[:l[k][1]] + '*' + s[l[k][1] + 1:]
			print(s)


test_cases = int(input())
for test_case in range(test_cases):
	matrix_size = int(input())
	matrix = []
	for row in range(matrix_size):
		matrix.append(list(input()))
	coordinates = []
	row = 0
	while row < matrix_size:
		column = 0
		while column < matrix_size:
			if matrix[row][column] == '*':
				coordinates.append((row, column))
			if len(coordinates) == 2:
				break
			column += 1
		if len(coordinates) == 2:
			break
		row += 1
	if coordinates[0][0] == coordinates[1][0]:
		if coordinates[0][0] == 0:
			matrix[coordinates[0][0] + 1][coordinates[0][1]] = '*'
			matrix[coordinates[1][0] + 1][coordinates[1][1]] = '*'
		else:
			matrix[coordinates[0][0] - 1][coordinates[0][1]] = '*'
			matrix[coordinates[1][0] - 1][coordinates[1][1]] = '*'
	elif coordinates[0][1] == coordinates[1][1]:
		if coordinates[0][1] == 0:
			matrix[coordinates[0][0]][coordinates[0][1] + 1] = '*'
			matrix[coordinates[1][0]][coordinates[1][1] + 1] = '*'
		else:
			matrix[coordinates[0][0]][coordinates[0][1] - 1] = '*'
			matrix[coordinates[1][0]][coordinates[1][1] - 1] = '*'
	else:
		matrix[coordinates[0][0]][coordinates[1][1]] = '*'
		matrix[coordinates[1][0]][coordinates[0][1]] = '*'
	for row in matrix:
		for column in row:
			print(column, end='')
		print()


def find(li):
	indices = []
	for i in range(0, len(li)):
		for j in range(0, len(li)):
			if li[i][j] == '*':
				indices.append(i)
				indices.append(j)
	x1 = indices[0]
	y1 = indices[1]
	x2 = indices[2]
	y2 = indices[3]
	if x1 != x2 and y1 != y2:
		li[x1][y2] = '*'
		li[x2][y1] = '*'
	elif x1 == x2:
		if x1 == x2 == len(li) - 1:
			li[x1 - 1][y1] = '*'
			li[x2 - 1][y2] = '*'
		else:
			li[x1 + 1][y1] = '*'
			li[x2 + 1][y2] = '*'
	elif y1 == y2:
		if y1 == y2 == len(li) - 1:
			li[x1][y1 - 1] = '*'
			li[x2][y2 - 1] = '*'
		else:
			li[x1][y1 + 1] = '*'
			li[x2][y2 + 1] = '*'
	for i in li:
		print(''.join(i))
n = int(input())
for i in range(0, n):
	l = int(input())
	li = []
	for i in range(0, l):
		x = list(str(input()))
		li.append(x)
	find(li)


def solve():
	n = int(input())
	idx1 = -1
	idy1 = -1
	idx2 = -1
	idy2 = -1
	mark = True
	for i in range(n):
		a = input()
		for j in range(n):
			if a[j] == '*':
				if mark:
					idx1 = j
					idy1 = i
					mark = False
				else:
					idx2 = j
					idy2 = i
	if idx1 == idx2:
		if idx1 == 0:
			for i in range(n):
				for j in range(n):
					if j == idx1 and i == idy1:
						print('*', end='')
					elif j == idx1 + 1 and i == idy1:
						print('*', end='')
					elif j == idx2 and i == idy2:
						print('*', end='')
					elif j == idx2 + 1 and i == idy2:
						print('*', end='')
					else:
						print('.', end='')
				print('')
		else:
			for i in range(n):
				for j in range(n):
					if j == idx1 and i == idy1:
						print('*', end='')
					elif j == idx1 - 1 and i == idy1:
						print('*', end='')
					elif j == idx2 and i == idy2:
						print('*', end='')
					elif j == idx2 - 1 and i == idy2:
						print('*', end='')
					else:
						print('.', end='')
				print('')
		return 0
	if idy1 == idy2:
		if idy1 == 0:
			for i in range(n):
				for j in range(n):
					if j == idx1 and i == idy1:
						print('*', end='')
					elif j == idx1 and i == idy1 + 1:
						print('*', end='')
					elif j == idx2 and i == idy2:
						print('*', end='')
					elif j == idx2 and i == idy2 + 1:
						print('*', end='')
					else:
						print('.', end='')
				print('')
		else:
			for i in range(n):
				for j in range(n):
					if j == idx1 and i == idy1:
						print('*', end='')
					elif j == idx1 and i == idy1 - 1:
						print('*', end='')
					elif j == idx2 and i == idy2:
						print('*', end='')
					elif j == idx2 and i == idy2 - 1:
						print('*', end='')
					else:
						print('.', end='')
				print('')
		return 0
	for i in range(n):
		for j in range(n):
			if j == idx1 and i == idy1:
				print('*', end='')
			elif j == idx2 and i == idy1:
				print('*', end='')
			elif j == idx2 and i == idy2:
				print('*', end='')
			elif j == idx1 and i == idy2:
				print('*', end='')
			else:
				print('.', end='')
		print('')
	return 0
T = int(input())
for i in range(T):
	solve()


for x in range(int(input())):
	n = int(input())
	l = []
	m = []
	for i in range(n):
		s = input()
		sb = []
		for e in s:
			sb.append(e)
		l.append(sb)
		for j in range(n):
			if s[j] == '*':
				m.append([i, j])
	(x1, x2, y1, y2) = (m[0][0], m[1][0], m[0][1], m[1][1])
	if x1 != x2 and y1 != y2:
		l[x1][y2] = '*'
		l[x2][y1] = '*'
	elif x1 == x2:
		sp = (abs(y1 - y2) + x1) % n
		l[sp][y1] = '*'
		l[sp][y2] = '*'
	else:
		sp = (abs(x1 - x2) + y1) % n
		l[x1][sp] = '*'
		l[x2][sp] = '*'
	for ll in l:
		print(''.join(ll))


t = int(input())
for k in range(t):
	n = int(input())
	q = 0
	(l, x, y) = ([], [], [])
	for i in range(n):
		s = input()
		l.append(s)
		if q < 2:
			for j in range(n):
				if s[j] == '*':
					x.append(i)
					y.append(j)
					q += 1
	(x1, y1) = (x[0], y[0])
	(x2, y2) = (x[1], y[1])
	if y1 != y2 and x1 != x2:
		l[x1] = l[x1][:y2] + '*' + l[x1][y2 + 1:]
		l[x2] = l[x2][:y1] + '*' + l[x2][y1 + 1:]
	elif x1 != x2:
		if y1 != 0:
			l[x1] = '*' + l[x1][1:]
			l[x2] = '*' + l[x2][1:]
		else:
			l[x1] = '**' + l[x1][2:]
			l[x2] = '**' + l[x2][2:]
	elif x1 != 0:
		l[0] = l[x1]
	else:
		l[1] = l[0]
	for i in l:
		print(i)


def split(a):
	l = []
	for i in a:
		l.append(i)
	return l

def join(a):
	w = ''
	for i in a:
		w = w + i
	return w
for _ in range(int(input())):
	n = int(input())
	l = []
	for i in range(n):
		k = input()
		l.append(split(k))
	r = []
	for i in range(n):
		for j in range(n):
			if l[i][j] == '*':
				r.append([i, j])
	if r[0][0] != r[1][0] and r[0][1] != r[1][1]:
		l[r[0][0]][r[1][1]] = '*'
		l[r[1][0]][r[0][1]] = '*'
	elif r[0][0] != r[1][0] and r[0][1] == r[1][1]:
		if r[0][1] == n - 1 or (r[0][1] < n - 1 and r[0][1] != 0):
			l[r[0][0]][0] = '*'
			l[r[1][0]][0] = '*'
		else:
			l[r[0][0]][n - 1] = '*'
			l[r[1][0]][n - 1] = '*'
	elif r[0][0] == n - 1 or (r[0][0] < n - 1 and r[0][0] != 0):
		l[0][r[0][1]] = '*'
		l[0][r[1][1]] = '*'
	else:
		l[n - 1][r[0][1]] = '*'
		l[n - 1][r[1][1]] = '*'
	for i in range(n):
		print(join(l[i]))


for _ in range(int(input())):
	n = int(input())
	arr = []
	for _ in range(n):
		s = list(input())
		arr.append(s)
	temp = []
	for i in range(n):
		for j in range(n):
			if arr[i][j] == '*':
				temp.append([i, j])
	(x1, y1) = (temp[0][0], temp[0][1])
	(x2, y2) = (temp[1][0], temp[1][1])
	if x1 == x2:
		if x1 + 1 < n:
			arr[x1 + 1][y1] = '*'
			arr[x2 + 1][y2] = '*'
		elif x1 - 1 >= 0:
			arr[x1 - 1][y1] = '*'
			arr[x2 - 1][y2] = '*'
	elif y1 == y2:
		if y1 + 1 < n:
			arr[x1][y1 + 1] = '*'
			arr[x2][y2 + 1] = '*'
		elif y1 - 1 >= 0:
			arr[x1][y1 - 1] = '*'
			arr[x2][y2 - 1] = '*'
	else:
		arr[x1][y2] = '*'
		arr[x2][y1] = '*'
	for i in range(n):
		print(''.join(arr[i]))


for _ in range(int(input())):
	n = int(input())
	arr = list()
	ind = []
	for i in range(n):
		row = list(input())
		for j in range(n):
			if row[j] == '*':
				ind.append([i, j])
		arr.append(row)
	if ind[0][0] == ind[1][0]:
		if ind[0][0] == n - 1:
			x = -1
		else:
			x = 1
		arr[ind[0][0] + x][ind[0][1]] = '*'
		arr[ind[1][0] + x][ind[1][1]] = '*'
	elif ind[0][1] == ind[1][1]:
		if ind[0][1] == n - 1:
			x = -1
		else:
			x = 1
		arr[ind[0][0]][ind[0][1] + x] = '*'
		arr[ind[1][0]][ind[1][1] + x] = '*'
	elif ind[0][0] == 0 and ind[0][1] == 0 and (ind[1][0] == n - 1) and (ind[1][1] == n - 1):
		arr[ind[0][0]][ind[1][0]] = '*'
		arr[ind[1][0]][ind[0][0]] = '*'
	else:
		index1 = [ind[0][0], ind[1][1]]
		index2 = [ind[1][0], ind[0][1]]
		arr[index1[0]][index1[1]] = '*'
		arr[index2[0]][index2[1]] = '*'
	for i in arr:
		print(''.join(i))


t = int(input())
for _ in range(t):
	n = int(input())
	matrix = []
	cords = []
	for i in range(n):
		matrix.append(list(input()))
		for j in range(len(matrix[-1])):
			if matrix[i][j] == '*':
				cords.append([i, j])
	(x1, y1) = cords[0]
	(x2, y2) = cords[1]
	cords.append(cords[0])
	cords.append(cords[1])
	if x1 == x2:
		cords[2][0] = (cords[2][0] + 1) % n
		cords[3][0] = (cords[3][0] + 1) % n
	elif y1 == y2:
		cords[2][1] = (cords[2][1] + 1) % n
		cords[3][1] = (cords[3][1] + 1) % n
	else:
		(cords[2][0], cords[3][0]) = (cords[3][0], cords[2][0])
	matrix[cords[2][0]][cords[2][1]] = '*'
	matrix[cords[3][0]][cords[3][1]] = '*'
	for i in range(n):
		print(''.join(matrix[i]))


t = int(input())
for t in range(t):
	p = int(input())
	lst = []
	q = 0
	x1 = -1
	y1 = -1
	x2 = -1
	y2 = -1
	x = 0
	for i in range(p):
		lst1 = list(input())
		lst.append(lst1)
		if q == 1:
			if x2 == 0:
				lst[x1 + 1][y2] = '*'
				lst[x1 + 1][y1] = '*'
			q += 1
		for j in range(len(lst1)):
			if lst1[j] == '*':
				if x1 < 0:
					x1 = i
					y1 = j
				else:
					x2 = i
					y2 = j
		if x2 >= 0 and q == 0:
			if x1 == x2:
				if x1 == 0:
					q = 1
				else:
					lst[x1 - 1][y2] = '*'
					lst[x1 - 1][y1] = '*'
			elif lst[x1][y2] == '*':
				if y1 == 0:
					lst[x1][y1 + 1] = '*'
					lst[x2][y2 + 1] = '*'
				else:
					lst[x1][y1 - 1] = '*'
					lst[x2][y2 - 1] = '*'
			else:
				lst[x1][y2] = '*'
				lst[x2][y1] = '*'
			q = 1
	for i in lst:
		for j in i:
			print(j, end='')
		print()


for t in range(int(input())):
	n = int(input())
	arr = [list(input()) for i in range(n)]
	points = []
	for i in range(n):
		for j in range(n):
			if arr[i][j] == '*':
				points.append([i, j])
		if len(points) == 2:
			break
	(i1, j1) = points[0]
	(i2, j2) = points[1]
	if i1 == i2:
		if i1 == n - 1:
			arr[0][j1] = '*'
			arr[0][j2] = '*'
		else:
			arr[n - 1][j1] = '*'
			arr[n - 1][j2] = '*'
	elif j1 == j2:
		if j1 == n - 1:
			arr[i1][0] = '*'
			arr[i2][0] = '*'
		else:
			arr[i1][n - 1] = '*'
			arr[i2][n - 1] = '*'
	else:
		arr[i1][j2] = '*'
		arr[i2][j1] = '*'
	for i in arr:
		print(''.join(i))


import sys
import typing

def rl(proc=None) -> typing.Any:
	if proc is not None:
		return proc(sys.stdin.readline())
	else:
		return sys.stdin.readline().rstrip()

def srl(proc=None) -> typing.List[typing.Any]:
	if proc is not None:
		return list(map(proc, rl().split()))
	else:
		return rl().split()

def main():
	T = rl(int)
	for t in range(1, T + 1):
		n = rl(int)
		A = [list(rl()) for _ in range(n)]
		pos = []
		for i in range(n):
			for j in range(n):
				if A[i][j] == '*':
					pos.append((i, j))
		(x1, y1) = pos[0]
		(x2, y2) = pos[1]
		if x1 == x2:
			x = x1 - 1
			if x < 0:
				x += 2
			A[x][y1] = '*'
			A[x][y2] = '*'
		elif y1 == y2:
			y = y1 - 1
			if y < 0:
				y += 2
			A[x1][y] = '*'
			A[x2][y] = '*'
		else:
			A[x1][y2] = '*'
			A[x2][y1] = '*'
		for row in A:
			print(''.join(row))
main()


t = int(input())
for _ in range(t):
	n = int(input())
	a = []
	s = []
	for i in range(n):
		l = list(map(str, input().split()))
		d = list(l[0])
		a.append(d)
	for i in range(n):
		for j in range(n):
			if a[i][j] == '*':
				s.append([i, j])
	if s[0][0] == s[1][0]:
		if s[0][0] != 0:
			a[s[0][0] - 1][s[0][1]] = '*'
			a[s[1][0] - 1][s[1][1]] = '*'
		else:
			a[s[0][0] + 1][s[0][1]] = '*'
			a[s[1][0] + 1][s[1][1]] = '*'
	elif s[0][1] == s[1][1]:
		if s[0][1] == 0:
			a[s[0][0]][s[0][1] + 1] = '*'
			a[s[1][0]][s[1][1] + 1] = '*'
		else:
			a[s[0][0]][s[0][1] - 1] = '*'
			a[s[1][0]][s[1][1] - 1] = '*'
	else:
		a[s[0][0]][s[1][1]] = '*'
		a[s[1][0]][s[0][1]] = '*'
	for i in a:
		for j in i:
			print(j, end='')
		print()


def zamien(wiersz):
	lista = []
	for i in range(len(wiersz)):
		if wiersz[i] == '*':
			lista.append(1)
		else:
			lista.append(0)
	return lista

def znajdz(lista):
	n = len(lista)
	wynik = []
	for i in range(n):
		for x in range(n):
			if lista[i][x] == 1:
				wynik.append([i, x])
	return wynik

def kwadrat(x, y, lista):
	if x[0] != y[0] and x[1] != y[1]:
		lista[x[0]][y[1]] = 1
		lista[y[0]][x[1]] = 1
	elif x[0] == y[0]:
		if x[0] != 0:
			lista[y[0] - 1][x[1]] = 1
			lista[x[0] - 1][y[1]] = 1
		else:
			lista[y[0] + 1][x[1]] = 1
			lista[x[0] + 1][y[1]] = 1
	elif x[1] != 0:
		lista[y[0]][x[1] - 1] = 1
		lista[x[0]][y[1] - 1] = 1
	else:
		lista[y[0]][x[1] + 1] = 1
		lista[x[0]][y[1] + 1] = 1
	return lista

def napraw(lista):
	wynik = []
	n = len(lista)
	for i in range(n):
		for x in range(n):
			if lista[i][x] == 0:
				print('.', end='')
			else:
				print('*', end='')
		print('')
n = int(input())
for i in range(n):
	k = int(input())
	lista = []
	for x in range(k):
		wiersz = input()
		wiersz.join(' ')
		wiersz.split()
		lista.append(zamien(wiersz))
	poz = znajdz(lista)
	lista = kwadrat(poz[0], poz[1], lista)
	napraw(lista)


from collections import deque as de
import math
from collections import Counter as cnt
from functools import reduce
from typing import MutableMapping
from itertools import groupby as gb
from fractions import Fraction as fr

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

class My_stack:

	def __init__(self):
		self.data = []

	def my_push(self, x):
		return self.data.append(x)

	def my_pop(self):
		return self.data.pop()

	def my_peak(self):
		return self.data[-1]

	def my_contains(self, x):
		return self.data.count(x)

	def my_show_all(self):
		return self.data

	def isEmpty(self):
		return len(self.data) == 0
arrStack = My_stack()

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def get_prime_factors(number):
	prime_factors = []
	while number % 2 == 0:
		prime_factors.append(2)
		number = number / 2
	for i in range(3, int(math.sqrt(number)) + 1, 2):
		while number % i == 0:
			prime_factors.append(int(i))
			number = number / i
	if number > 2:
		prime_factors.append(int(number))
	return prime_factors

def get_frequency(list):
	dic = {}
	for ele in list:
		if ele in dic:
			dic[ele] += 1
		else:
			dic[ele] = 1
	return dic

def Log2(x):
	return math.log10(x) / math.log10(2)

def isPowerOfTwo(n):
	return math.ceil(Log2(n)) == math.floor(Log2(n))

def ceildiv(x, y):
	return (x + y - 1) // y

def di():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))
t = int(input())
while t:
	t -= 1
	n = int(input())
	l = [list(map(str, input())) for i in range(n)]
	ans = []
	for i in range(n):
		for j in range(n):
			if l[i][j] == '*':
				ans.append([i, j])
	r1 = ans[0][0]
	c1 = ans[0][1]
	r2 = ans[1][0]
	c2 = ans[1][1]
	print
	if r1 == r2:
		if r1 != n - 1:
			l[r1 + 1][c1] = l[r1 + 1][c2] = '*'
		else:
			l[r1 - 1][c1] = l[r1 - 1][c2] = '*'
	elif c1 == c2:
		if c1 != n - 1:
			l[r1][c1 + 1] = l[r2][c2 + 1] = '*'
		else:
			l[r1][c1 - 1] = l[r2][c2 - 1] = '*'
	else:
		l[r1][c2] = l[r2][c1] = '*'
	for i in range(n):
		for j in range(n):
			print(l[i][j], end='')
		print(end='\n')


t = int(input())
out = []
for case in range(t):
	n = int(input())
	table = []
	p1x = -1
	p1y = -1
	p2x = -1
	p2y = -1
	for i in range(n):
		row = input()
		table.append(list(row))
		if '*' in row:
			count = 0
			for (j, point) in enumerate(row):
				if point == '*':
					count += 1
					if p1x == -1:
						p1x = j
						p1y = i
					else:
						p2x = j
						p2y = i
	p3x = -1
	p3y = -1
	p4x = -1
	p4y = -1
	if p1x == p2x:
		p3y = p1y
		p4y = p2y
		dist = p2y - p1y
		if p1x + dist < n:
			p3x = p1x + dist
			p4x = p2x + dist
		else:
			p3x = p1x - dist
			p4x = p2x - dist
	elif p1y == p2y:
		p3x = p1x
		p4x = p2x
		dist = p2x - p1x
		if p1y + dist < n:
			p3y = p1y + dist
			p4y = p2y + dist
		else:
			p3y = p1y - dist
			p4y = p2y - dist
	else:
		p3x = p1x
		p3y = p2y
		p4x = p2x
		p4y = p1y
	table[p3y][p3x] = '*'
	table[p4y][p4x] = '*'
	out.append('\n'.join([''.join(row) for row in table]))
print('\n'.join(out))


from math import *
t = int(input())
for _ in range(t):
	n = int(input())
	l = []
	arr = []
	for i in range(n):
		s = input()
		arr.append(s)
		if '*' in s and s.count('*') == 1:
			l.append([i, s.index('*'), s])
		elif '*' in s and s.count('*') == 2:
			l.append([i, s])
	if len(l) == 2:
		if l[0][1] != l[1][1]:
			new = ''
			for (x, y) in zip(l[0][2], l[1][2]):
				if x != y:
					new = new + '*'
				else:
					new = new + '.'
		else:
			new = ''
			c = 1
			for (x, y) in zip(l[0][2], l[1][2]):
				if x == y == '.' and c:
					new = new + '*'
					c = 0
				elif x == y == '*':
					new = new + '*'
				else:
					new = new + '.'
		arr[l[0][0]] = new
		arr[l[1][0]] = new
		for i in arr:
			print(i)
	else:
		c = 1
		for i in arr:
			if i != l[0][1] and c:
				print(l[0][1])
				c = 0
			else:
				print(i)


t = int(input())
for i in range(t):
	l = int(input())
	matrix = []
	p = []
	for i in range(l):
		x = list(str(input()))
		matrix.append(x)
		for j in range(l):
			if matrix[i][j] == '*':
				p.append((i, j))
	(r1, c1) = (p[0][0], p[0][1])
	(r2, c2) = (p[1][0], p[1][1])
	if c1 == c2:
		if c1 == 0:
			matrix[r1][1] = '*'
			matrix[r2][1] = '*'
		else:
			matrix[r1][0] = '*'
			matrix[r2][0] = '*'
	elif r1 == r2:
		if r1 == 0:
			matrix[1][c1] = '*'
			matrix[1][c2] = '*'
		else:
			matrix[0][c1] = '*'
			matrix[0][c2] = '*'
	else:
		matrix[r1][c2] = '*'
		matrix[r2][c1] = '*'
	for i in range(l):
		print(''.join(matrix[i]))


for _ in range(int(input())):
	n = int(input())
	f = []
	for __ in range(n):
		f1 = list(input())
		f.append(f1)
	(r1, c1, r2, c2) = (0, 0, 0, 0)
	for i in range(n):
		for j in range(n):
			if f[i][j] == '*':
				if r1 == 0:
					r1 = i + 1
					c1 = j + 1
				else:
					r2 = i + 1
					c2 = j + 1
					break
	if r1 == r2:
		if r1 == n:
			f[r1 - 2][c1 - 1] = '*'
			f[r2 - 2][c2 - 1] = '*'
		else:
			f[r1][c1 - 1] = '*'
			f[r2][c2 - 1] = '*'
	elif c1 == c2:
		if c1 == n:
			f[r1 - 1][c1 - 2] = '*'
			f[r2 - 1][c2 - 2] = '*'
		else:
			f[r1 - 1][c1] = '*'
			f[r2 - 1][c2] = '*'
	elif c1 > c2:
		f[r1 - 1][c2 - 1] = '*'
		f[r2 - 1][c1 - 1] = '*'
	else:
		f[r1 - 1][c2 - 1] = '*'
		f[r2 - 1][c1 - 1] = '*'
	for i in f:
		for j in i:
			print(j, end='')
		print()


from collections import *
TT = int(input())
for y in range(TT):
	n = int(input())
	lst = []
	arr = []
	for i in range(n):
		lst.append(list(input()))
		for j in range(n):
			if lst[i][j] == '*':
				arr.append([i, j])
	a = arr[0][0]
	b = arr[0][1]
	c = arr[1][0]
	d = arr[1][1]
	lst[a][b] = '*'
	lst[a][d] = '*'
	lst[c][b] = '*'
	lst[c][d] = '*'
	if a == c:
		if a == 0:
			c = 1
			lst[a][b] = '*'
			lst[a][d] = '*'
			lst[c][b] = '*'
			lst[c][d] = '*'
		else:
			c = 0
			lst[a][b] = '*'
			lst[a][d] = '*'
			lst[c][b] = '*'
			lst[c][d] = '*'
	if b == d:
		if b == 0:
			d = 1
			lst[a][b] = '*'
			lst[a][d] = '*'
			lst[c][b] = '*'
			lst[c][d] = '*'
		else:
			d = 0
			lst[a][b] = '*'
			lst[a][d] = '*'
			lst[c][b] = '*'
			lst[c][d] = '*'
	for i in lst:
		print(''.join(i))


t = int(input())
for _ in range(t):
	n = int(input())
	matrix = []
	coords = []
	for i in range(n):
		a = list(input())
		for j in range(n):
			if a[j] == '*':
				coords.append([i, j])
		matrix.append(a)
	posA = coords[0]
	posB = coords[1]
	if posA[0] == posB[0]:
		matrix[posA[0] - 1][posA[1]] = '*'
		matrix[posA[0] - 1][posB[1]] = '*'
	elif posA[1] == posB[1]:
		matrix[posA[0]][posA[1] - 1] = '*'
		matrix[posB[0]][posA[1] - 1] = '*'
	else:
		matrix[posA[0]][posB[1]] = '*'
		matrix[posB[0]][posA[1]] = '*'
	for row in matrix:
		for item in row:
			print(item, end='')
		print()


results = []
for i in range(int(input())):
	n = int(input())
	matrix = []
	c = []
	row = []
	for j in range(n):
		row = input()
		matrix.append(list(row))
	rect_length = 0
	c = [[e, f] for e in range(n) for f in range(n) if matrix[e][f] == '*']
	(x1, y1, x2, y2) = (c[0][0], c[0][1], c[1][0], c[1][1])
	if c[0][::-1] == c[1] or (x1 == y1 and x2 == y2) or (x1 != x2 and y1 != y2):
		matrix[x1][y2] = '*'
		matrix[x2][y1] = '*'
	elif x1 == x2:
		x3 = x1 + 1 if x1 == 0 else x1 - 1
		matrix[x3][y1] = '*'
		matrix[x3][y2] = '*'
	elif y1 == y2:
		y3 = y1 + 1 if y1 == 0 else y1 - 1
		matrix[x1][y3] = '*'
		matrix[x2][y3] = '*'
	results.append(matrix)
for m in results:
	for ro in m:
		print(''.join(ro))


from sys import stdin, stdout
from os import path
rd = lambda : stdin.readline().strip()
wr = stdout.write
if path.exists('input.txt'):
	stdin = open('input.txt', 'r')
import time, math
for _ in range(int(rd())):
	x = int(rd())
	arr = []
	mylist = []
	for i in range(x):
		y = rd()
		index = y.find('*')
		mylist.append(y)
		if index == -1:
			continue
		else:
			if '*' in y[index + 1:]:
				z = y.rfind('*')
				arr.append((i, z))
			arr.append((i, index))
	arr.sort()
	out = []
	if arr[0][0] == arr[1][0]:
		if arr[0][0] == x - 1:
			out.append((arr[0][0] - 1, arr[0][1]))
			out.append((arr[0][0] - 1, arr[1][1]))
		else:
			out.append((arr[0][0] + 1, arr[0][1]))
			out.append((arr[0][0] + 1, arr[1][1]))
	elif arr[0][1] == arr[1][1]:
		if arr[0][1] == x - 1:
			out.append((arr[0][0], arr[0][1] - 1))
			out.append((arr[1][0], arr[1][1] - 1))
		else:
			out.append((arr[0][0], arr[0][1] + 1))
			out.append((arr[1][0], arr[1][1] + 1))
	else:
		out.append((arr[0][0], arr[1][1]))
		out.append((arr[1][0], arr[0][1]))
	mylist[out[0][0]] = mylist[out[0][0]][:out[0][1]] + '*' + mylist[out[0][0]][out[0][1] + 1:]
	mylist[out[1][0]] = mylist[out[1][0]][:out[1][1]] + '*' + mylist[out[1][0]][out[1][1] + 1:]
	for i in range(x):
		print(mylist[i])


t = int(input())
for z in range(t):
	n = int(input())
	a = []
	for i in range(n):
		b = list(input())
		if b[len(b) - 1] == '\r':
			b.pop()
		a.append(b)
	d = []
	for i in range(len(a)):
		for j in range(len(a[i])):
			if a[i][j] == '*':
				d.append([i, j])
	if d[0][0] == d[1][0]:
		if d[0][0] < len(a) - 1:
			a[d[0][0] + 1][d[0][1]] = '*'
			a[d[1][0] + 1][d[1][1]] = '*'
		else:
			a[d[0][0] - 1][d[0][1]] = '*'
			a[d[1][0] - 1][d[1][1]] = '*'
	else:
		p = d[0][1] - d[1][1]
		if p == 0:
			if d[0][1] < len(a) - 1:
				a[d[0][0]][d[0][1] + 1] = '*'
				a[d[1][0]][d[1][1] + 1] = '*'
			else:
				a[d[0][0]][d[0][1] - 1] = '*'
				a[d[1][0]][d[1][1] - 1] = '*'
		else:
			a[d[0][0]][d[1][1]] = '*'
			a[d[1][0]][d[0][1]] = '*'
	for i in range(len(a)):
		for j in range(len(a[i])):
			print(a[i][j], end='')
		print()


for i in range(int(input())):
	ind = []
	l = []
	n = int(input())
	for j in range(n):
		l.append([*input()])
	i1 = 0
	i2 = 0
	for a in range(len(l)):
		for b in range(len(l)):
			if l[a][b] == '*':
				ind.append(a)
				ind.append(b)
	if ind[1] != ind[3] and ind[0] != ind[2]:
		l[ind[0]][ind[3]] = '*'
		l[ind[2]][ind[1]] = '*'
	elif ind[1] == ind[3]:
		if ind[1] != n - 1:
			l[ind[0]][ind[3] + 1] = '*'
			l[ind[2]][ind[1] + 1] = '*'
		else:
			l[ind[0]][ind[3] - 1] = '*'
			l[ind[2]][ind[1] - 1] = '*'
	elif ind[0] == ind[2]:
		if ind[0] != n - 1:
			l[ind[0] + 1][ind[3]] = '*'
			l[ind[2] + 1][ind[1]] = '*'
		else:
			l[ind[0] - 1][ind[3]] = '*'
			l[ind[2] - 1][ind[1]] = '*'
	for _ in l:
		print(''.join(_))


for _ in range(int(input())):
	n = int(input())
	starts = []
	arr = []
	for i in range(n):
		arr.append(input().strip())
		if '*' in arr[-1]:
			if arr[-1].count('*') == 1:
				starts.append((i, arr[-1].index('*')))
			elif arr[-1].count('*') == 2:
				starts.append((i, arr[-1].index('*')))
				starts.append((i, n - 1 - arr[-1][::-1].index('*')))
	if starts[0][0] == starts[1][0]:
		x = starts[0][0]
		if x < n - 1:
			arr[x + 1] = arr[x]
		else:
			arr[x - 1] = arr[x]
	elif starts[0][1] == starts[1][1]:
		x = starts[0][1]
		if x != 0:
			arr[starts[0][0]] = '*' + arr[starts[0][0]][1:]
			arr[starts[1][0]] = '*' + arr[starts[1][0]][1:]
		else:
			arr[starts[0][0]] = '**' + arr[starts[0][0]][2:]
			arr[starts[1][0]] = '**' + arr[starts[1][0]][2:]
	else:
		res = ''
		for i in range(n):
			if arr[starts[0][0]][i] == '*' or arr[starts[1][0]][i] == '*':
				res = res + '*'
			else:
				res = res + '.'
		arr[starts[0][0]] = res
		arr[starts[1][0]] = res
	print(*arr, sep='\n')


for i in range(int(input())):
	n = int(input())
	l = []
	for i in range(n):
		a = list(input())
		l.append(a)
	count = 0
	for i in range(n):
		for j in range(n):
			if l[i][j] == '*':
				count += 1
				if count == 1:
					a = i
					b = j
				else:
					c = i
					d = j
	if a == c:
		if a != n - 1:
			l[a + 1][b] = '*'
			l[c + 1][d] = '*'
		else:
			l[a - 1][b] = '*'
			l[c - 1][d] = '*'
	elif b == d:
		if b != n - 1:
			l[a][b + 1] = '*'
			l[c][d + 1] = '*'
		else:
			l[a][b - 1] = '*'
			l[c][d - 1] = '*'
	else:
		l[c][b] = '*'
		l[a][d] = '*'
	for i in l:
		for j in i:
			print(j, end='')
		print('')


t = int(input())
while t:
	t -= 1
	n = int(input())
	S = []
	_ = []
	for i in range(n):
		S.append([])
	for i in range(n):
		a = list(map(str, input()))
		if '*' in a:
			_.append([i, a.index('*')])
			if a.count('*') != 1:
				_.append([i, n - 1 - a[::-1].index('*')])
		S[i] = a
	if _[0][0] == _[1][0]:
		if _[0][0] + abs(_[0][1] - _[1][1]) > n - 1:
			S[_[0][0] - abs(_[0][1] - _[1][1])][_[0][1]] = '*'
			S[_[0][0] - abs(_[0][1] - _[1][1])][_[1][1]] = '*'
		else:
			S[_[0][0] + abs(_[0][1] - _[1][1])][_[0][1]] = '*'
			S[_[0][0] + abs(_[0][1] - _[1][1])][_[1][1]] = '*'
	elif _[0][1] == _[1][1]:
		if _[0][1] + abs(_[0][0] - _[1][0]) > n - 1:
			S[_[0][0]][_[0][1] - abs(_[0][0] - _[1][0])] = '*'
			S[_[1][0]][_[0][1] - abs(_[0][0] - _[1][0])] = '*'
		else:
			S[_[0][0]][_[0][1] + abs(_[0][0] - _[1][0])] = '*'
			S[_[1][0]][_[0][1] + abs(_[0][0] - _[1][0])] = '*'
	else:
		S[_[0][0]][_[1][1]] = '*'
		S[_[1][0]][_[0][1]] = '*'
	for i in S:
		print(*i, sep='')


import sys
import math
from collections import Counter, defaultdict
LI = lambda : list(map(int, input().split()))
MAP = lambda : map(int, input().split())
IN = lambda : int(input())
S = lambda : input()

def case():
	n = IN()
	a = []
	b = []
	for i in range(n):
		s = list(S())
		for j in range(n):
			if s[j] == '*':
				b.append((i, j))
		a += [s]
	if b[0][0] == b[1][0]:
		if b[0][0] == n - 1:
			a[b[0][0] - 1][b[0][1]] = '*'
			a[b[1][0] - 1][b[1][1]] = '*'
		else:
			a[b[0][0] + 1][b[0][1]] = '*'
			a[b[1][0] + 1][b[1][1]] = '*'
	elif b[0][1] == b[1][1]:
		if b[0][1] == n - 1:
			a[b[0][0]][b[0][1] - 1] = '*'
			a[b[1][0]][b[1][1] - 1] = '*'
		else:
			a[b[0][0]][b[0][1] + 1] = '*'
			a[b[1][0]][b[1][1] + 1] = '*'
	else:
		a[b[0][0]][b[1][1]] = '*'
		a[b[1][0]][b[0][1]] = '*'
	for i in a:
		print(*i, sep='')
for _ in range(IN()):
	case()


import sys
import collections
from collections import Counter, deque
import itertools
import math
import timeit
import random

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def minmax(a, b):
	return (a, b) if a < b else (b, a)
for _ in range(ii()):
	n = ii()
	m = []
	d = []
	for i in range(n):
		tmp = []
		for (j, p) in enumerate(input()):
			tmp.append(p)
			if p == '*':
				d.append((i, j))
		m.append(tmp)
	(a, b) = (d[0], d[1])
	if a[0] == b[0]:
		m[(a[0] + 1) % n][a[1]] = '*'
		m[(b[0] + 1) % n][b[1]] = '*'
	elif a[1] == b[1]:
		m[a[0]][(a[1] + 1) % n] = '*'
		m[b[0]][(b[1] + 1) % n] = '*'
	else:
		m[b[0]][a[1]] = '*'
		m[a[0]][b[1]] = '*'
	for i in range(n):
		print(*m[i], sep='')


t = int(input())
for _ in range(t):
	n = int(input())
	first_corner = None
	second_corner = None
	field = []
	for i in range(n):
		line = input()
		field.append(line)
		if '*' in line and (not first_corner):
			first_corner = [i, line.index('*')]
			if first_corner[1] != n - 1 and '*' in line[first_corner[1] + 1:]:
				second_corner = [i, line.index('*', first_corner[1] + 1)]
		elif '*' in line:
			second_corner = [i, line.index('*')]
	third_corner = []
	fourth_corner = []
	if first_corner[0] == second_corner[0]:
		if first_corner[0] == 0:
			third_corner = [1, first_corner[1]]
			fourth_corner = [1, second_corner[1]]
		else:
			third_corner = [first_corner[0] - 1, first_corner[1]]
			fourth_corner = [second_corner[0] - 1, second_corner[1]]
	elif first_corner[1] == second_corner[1]:
		if first_corner[1] == 0:
			third_corner = [first_corner[0], 1]
			fourth_corner = [second_corner[0], 1]
		else:
			third_corner = [first_corner[0], first_corner[1] - 1]
			fourth_corner = [second_corner[0], second_corner[1] - 1]
	else:
		third_corner = [first_corner[0], second_corner[1]]
		fourth_corner = [second_corner[0], first_corner[1]]
	third_corner_line = field[third_corner[0]]
	field[third_corner[0]] = third_corner_line[:third_corner[1]] + '*' + third_corner_line[third_corner[1] + 1:]
	fourth_corner_line = field[fourth_corner[0]]
	field[fourth_corner[0]] = fourth_corner_line[:fourth_corner[1]] + '*' + fourth_corner_line[fourth_corner[1] + 1:]
	for line in field:
		print(line)


from sys import *
from collections import defaultdict as dd
from math import *
from bisect import *

def sinp():
	return input()

def inp():
	return int(sinp())

def minp():
	return map(int, sinp().split())

def linp():
	return list(minp())

def strl():
	return list(sinp())

def pr(x):
	print(x)
mod = int(1000000000.0 + 7)
for _ in range(inp()):
	n = inp()
	mat = []
	for i in range(n):
		mat.append(list(input()))
	pos = []
	for i in range(n):
		for j in range(n):
			if mat[i][j] == '*':
				pos.append([i, j])
	if pos[0][0] == pos[1][0]:
		if pos[0][0] < n - 1:
			mat[pos[0][0] + 1][pos[0][1]] = '*'
			mat[pos[1][0] + 1][pos[1][1]] = '*'
		else:
			mat[pos[0][0] - 1][pos[0][1]] = '*'
			mat[pos[1][0] - 1][pos[1][1]] = '*'
	elif pos[0][1] == pos[1][1]:
		if pos[0][1] < n - 1:
			mat[pos[0][0]][pos[0][1] + 1] = '*'
			mat[pos[1][0]][pos[1][1] + 1] = '*'
		else:
			mat[pos[0][0]][pos[0][1] - 1] = '*'
			mat[pos[1][0]][pos[1][1] - 1] = '*'
	else:
		x = abs(pos[1][0] - pos[0][0])
		y = abs(pos[0][1] - pos[1][1])
		if pos[0][1] < pos[1][1]:
			mat[pos[0][0]][pos[0][1] + y] = '*'
			mat[pos[1][0]][pos[1][1] - y] = '*'
		else:
			mat[pos[0][0]][pos[0][1] - y] = '*'
			mat[pos[1][0]][pos[1][1] + y] = '*'
	for i in range(n):
		print(''.join(mat[i]))


import sys
input = sys.stdin.readline

def solve():
	n = int(input())
	a = [list(input().strip()) for i in range(n)]
	mx = int(1000000000.0)
	Mx = -1
	my = int(1000000000.0)
	My = -1
	for i in range(n):
		for j in range(n):
			if a[i][j] == '*':
				mx = min(mx, i)
				Mx = max(Mx, i)
				my = min(my, j)
				My = max(My, j)
	if mx == Mx:
		if mx > 0:
			mx -= 1
		else:
			Mx += 1
	if my == My:
		if my > 0:
			my -= 1
		else:
			My += 1
	a[mx][my] = '*'
	a[mx][My] = '*'
	a[Mx][my] = '*'
	a[Mx][My] = '*'
	for i in a:
		print(''.join(i))
for i in range(int(input())):
	solve()


test = int(input())
for i in range(test):
	rage = int(input())
	arr = []
	for j in range(rage):
		r = list(input())
		arr.append(r)
	ast = []
	for s in range(rage):
		for k in range(rage):
			if arr[s][k] == '*':
				ast.append((s, k))
	f_p = ast[0]
	s_p = ast[1]
	if f_p[0] == s_p[0]:
		if s_p[0] == rage - 1:
			arr[f_p[0] - 1][f_p[1]] = '*'
			arr[s_p[0] - 1][s_p[1]] = '*'
		else:
			arr[f_p[0] + 1][f_p[1]] = '*'
			arr[s_p[0] + 1][s_p[1]] = '*'
	elif f_p[1] == s_p[1]:
		if f_p[1] == rage - 1:
			arr[f_p[0]][f_p[1] - 1] = '*'
			arr[s_p[0]][s_p[1] - 1] = '*'
		else:
			arr[f_p[0]][f_p[1] + 1] = '*'
			arr[s_p[0]][s_p[1] + 1] = '*'
	else:
		x_dif = f_p[1] - s_p[1]
		arr[f_p[0]][f_p[1] - x_dif] = '*'
		arr[s_p[0]][s_p[1] + x_dif] = '*'
	for g in range(rage):
		arr[g] = ''.join(arr[g])
		print(arr[g])


test_cases = int(input())
rectangles = []
for test_case in range(test_cases):
	n = int(input())
	rows = []
	for _ in range(n):
		rows.append(input())
	rectangles.append(rows)
for rows in rectangles:
	star1 = None
	star2 = None
	for (i, row) in enumerate(rows):
		if row.count('*'):
			if not star1:
				star1 = (row.find('*'), i)
			else:
				star2 = (row.find('*'), i)
		if row.count('*') == 2:
			star2 = (row.rfind('*'), i)
	if star1[0] == star2[0]:
		x_coord = 0 if star1[0] != 0 else 1
		new_star1 = (x_coord, star1[1])
		new_star2 = (x_coord, star2[1])
	elif star1[1] == star2[1]:
		y_coord = 0 if star1[1] != 0 else 1
		new_star1 = (star1[0], y_coord)
		new_star2 = (star2[0], y_coord)
	else:
		new_star1 = (star2[0], star1[1])
		new_star2 = (star1[0], star2[1])
	for (i, row) in enumerate(rows):
		if new_star1[1] == i:
			x = new_star1[0]
			row = row[:x] + '*' + row[x + 1:]
		if new_star2[1] == i:
			x = new_star2[0]
			row = row[:x] + '*' + row[x + 1:]
		print(row)


num = int(input())
for i in range(num):
	n = int(input())
	arr = []
	row = []
	column = []
	for j in range(n):
		text = input()
		text = list(text)
		if '*' in text:
			for z in range(n):
				if text[z] == '*':
					row.append(j)
					column.append(z)
		arr.append(text)
	if row[0] == row[1]:
		if row[0] > 0:
			row[0] -= 1
			row[1] -= 1
		elif row[0] < n - 1:
			row[0] += 1
			row[1] += 1
	elif column[0] == column[1]:
		if column[0] > 0:
			column[0] -= 1
			column[1] -= 1
		elif column[0] < n - 1:
			column[0] += 1
			column[1] += 1
	else:
		temp = row[0]
		row[0] = row[1]
		row[1] = temp
	arr[row[0]][column[0]] = '*'
	arr[row[1]][column[1]] = '*'
	for k in range(n):
		print(''.join(arr[k]))


T = int(input())
for _ in range(T):
	N = int(input())
	G = []
	for i in range(N):
		G.append(list(input()))
	can = []
	(X, Y) = (set(), set())
	for i in range(N):
		for j in range(N):
			if G[i][j] == '*':
				can.append((i, j))
				X.add(i)
				Y.add(j)
	if len(X) == 2 and len(Y) == 2:
		G[min(X)][max(Y)] = '*'
		G[max(X)][min(Y)] = '*'
		G[min(X)][min(Y)] = '*'
		G[max(X)][max(Y)] = '*'
	elif len(X) == 1:
		for next_x in range(N):
			if next_x not in X:
				G[next_x][max(Y)] = '*'
				G[next_x][min(Y)] = '*'
				break
	else:
		for next_y in range(N):
			if next_y not in Y:
				G[min(X)][next_y] = '*'
				G[max(X)][next_y] = '*'
				break
	for i in range(N):
		print(''.join(G[i]))


t = int(input())
for z in range(t):
	n = int(input())
	l = []
	(a, b, c, d) = (-1, -1, -1, -1)
	k = 0
	for i in range(n):
		s = input()
		l.append(list(s))
	for i in range(n):
		for j in range(n):
			if l[i][j] == '*':
				if a == -1 and b == -1:
					a = i
					b = j
				else:
					c = i
					d = j
	if a == c:
		if a + 1 < n:
			l[a + 1][b] = '*'
			l[c + 1][d] = '*'
		else:
			l[a - 1][b] = '*'
			l[c - 1][d] = '*'
	elif b == d:
		if b + 1 < n:
			l[a][b + 1] = '*'
			l[c][d + 1] = '*'
		else:
			l[a][b - 1] = '*'
			l[c][d - 1] = '*'
	else:
		l[c][b] = '*'
		l[a][d] = '*'
	for r in l:
		print(''.join((k for k in r)))


for _ in range(int(input())):
	n = int(input())
	matrix = [list(input()) for _ in range(n)]
	(x1, y1, x2, y2) = (-1, 0, 0, 0)
	for row in range(n):
		s = matrix[row]
		if s.count('*') == 1:
			if x1 == -1:
				x1 = s.index('*')
				y1 = row
			else:
				x2 = s.index('*')
				y2 = row
				break
		elif s.count('*') == 2:
			x1 = s.index('*')
			y1 = row
			s[x1] = '.'
			x2 = s.index('*')
			y2 = row
			s[x1] = '*'
			break
	if x1 != x2 and y1 != y2:
		matrix[y1][x2] = '*'
		matrix[y2][x1] = '*'
	elif x1 != x2 and y1 == y2:
		if y1 - 1 >= 0:
			matrix[y1 - 1][x1] = '*'
			matrix[y1 - 1][x2] = '*'
		else:
			matrix[y1 + 1][x1] = '*'
			matrix[y1 + 1][x2] = '*'
	elif x1 - 1 >= 0:
		matrix[y1][x1 - 1] = '*'
		matrix[y2][x1 - 1] = '*'
	else:
		matrix[y1][x1 + 1] = '*'
		matrix[y2][x1 + 1] = '*'
	for row in matrix:
		print(''.join(row))


for _ in range(int(input())):
	n = int(input())
	arr = []
	for x in range(n):
		s = list(input())
		arr.append(s)
	req = []
	for x in range(len(arr)):
		for y in range(len(arr[0])):
			if arr[x][y] == '*':
				req.append((x, y))
	if req[0][0] != req[1][0] and req[0][1] != req[1][1]:
		arr[req[0][0]][req[1][1]] = '*'
		arr[req[1][0]][req[0][1]] = '*'
	elif req[0][0] == req[1][0]:
		if req[0][0] < n - 1:
			arr[req[0][0] + 1][req[0][1]] = '*'
			arr[req[1][0] + 1][req[1][1]] = '*'
		else:
			arr[req[0][0] - 1][req[0][1]] = '*'
			arr[req[1][0] - 1][req[1][1]] = '*'
	elif req[0][1] == req[1][1]:
		if req[0][1] < n - 1:
			arr[req[0][0]][req[0][1] + 1] = '*'
			arr[req[1][0]][req[1][1] + 1] = '*'
		else:
			arr[req[0][0]][req[0][1] - 1] = '*'
			arr[req[1][0]][req[1][1] - 1] = '*'
	for i in range(n):
		print(''.join(arr[i]))


T = int(input())
for _ in range(T):
	N = int(input())
	grid = [[*input()] for _ in range(N)]
	stars = [(x, y) for x in range(N) for y in range(N) if grid[x][y] == '*']
	if stars[0][0] == stars[1][0]:
		if stars[0][0] == 0:
			x = 1
		else:
			x = stars[0][0] - 1
		grid[x][stars[0][1]] = '*'
		grid[x][stars[1][1]] = '*'
	elif stars[0][1] == stars[1][1]:
		if stars[0][1] == 0:
			y = 1
		else:
			y = stars[0][1] - 1
		grid[stars[0][0]][y] = '*'
		grid[stars[1][0]][y] = '*'
	else:
		grid[stars[1][0]][stars[0][1]] = '*'
		grid[stars[0][0]][stars[1][1]] = '*'
	for row in grid:
		print(*row, sep='')


t = int(input())
for _ in range(t):
	n = int(input())
	array = []
	x = []
	y = []
	for i in range(0, n):
		arr = list(input())
		array.append(arr)
		if arr.count('*') == 1:
			x.append(arr.index('*') + 1)
			y.append(i + 1)
		elif arr.count('*') == 2:
			for j in range(0, n):
				if arr[j] == '*':
					x.append(j + 1)
					y.append(i + 1)
	if len(list(set(x))) > 1 and len(list(set(y))) > 1:
		array[y[1] - 1][x[0] - 1] = '*'
		array[y[0] - 1][x[1] - 1] = '*'
	elif len(list(set(x))) > 1:
		if y[0] < n:
			array[y[1]][x[0] - 1] = '*'
			array[y[0]][x[1] - 1] = '*'
		else:
			array[y[1] - 2][x[0] - 1] = '*'
			array[y[0] - 2][x[1] - 1] = '*'
	elif x[0] < n:
		array[y[1] - 1][x[0]] = '*'
		array[y[0] - 1][x[1]] = '*'
	else:
		array[y[1] - 1][x[0] - 2] = '*'
		array[y[0] - 1][x[1] - 2] = '*'
	for i in array:
		print(''.join(i))


a = eval(input())
for _ in range(a):
	b = eval(input())
	ls = []
	for i in range(b):
		c = input()
		for j in range(len(c)):
			if c[j] == '*':
				ls.append([i, j])
	y1 = ls[0][0]
	x1 = ls[0][1]
	y2 = ls[1][0]
	x2 = ls[1][1]
	x = []
	y = []
	if y1 == y2:
		x.append(x1)
		x.append(x2)
		if y1 + 1 < b:
			y.append(y1)
			y.append(y1 + 1)
		else:
			y.append(y1)
			y.append(y1 - 1)
	elif x1 == x2:
		y.append(y1)
		y.append(y2)
		if x1 + 1 < b:
			x.append(x1 + 1)
			x.append(x1)
		else:
			x.append(x1 - 1)
			x.append(x1)
	else:
		x.append(x1)
		x.append(x2)
		y.append(y1)
		y.append(y2)
	for i in range(b):
		l = ['.' for k in range(b)]
		if i in y:
			l[x[0]] = '*'
			l[x[1]] = '*'
		print(''.join(l))


t = int(input())
for _ in range(t):
	n = int(input())
	arr = []
	for i in range(n):
		x = list(input())
		arr.append(x)
	row1 = -1
	row2 = -1
	col1 = -1
	col2 = -1
	c = 0
	for i in range(len(arr)):
		for j in range(len(arr)):
			if arr[i][j] == '*':
				if row1 == -1 and col1 == -1:
					row1 = i
					col1 = j
				else:
					row2 = i
					col2 = j
					c = 1
					break
		if c == 1:
			break
	if col1 == col2:
		if col1 == 0:
			col1 += 1
			col2 += 1
		else:
			col1 -= 1
			col2 -= 1
	if row1 == row2:
		if row1 == 0:
			row1 += 1
			row2 += 1
		else:
			row2 -= 1
			row1 -= 1
	arr[row1][col2] = '*'
	arr[row2][col1] = '*'
	for i in arr:
		print(''.join(i))


from io import BytesIO, IOBase
import sys
import math
import os
from collections import defaultdict
from math import ceil
from bisect import bisect_left, bisect_left
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def mint():
	return map(int, input().split())

def mfloat():
	return map(float, input().split())

def solve():
	points = []
	n = int(input())
	for i in range(n):
		s = input()
		for j in range(n):
			if s[j] == '*':
				points.append([i, j])
	x = [points[0][0], points[1][0]]
	y = [points[0][1], points[1][1]]
	new_one = [0, 0]
	new_two = [0, 0]
	if x[0] == x[1]:
		new_one[0] = new_two[0] = (x[0] + 1) % n
		new_one[1] = y[0]
		new_two[1] = y[1]
	elif y[0] == y[1]:
		new_one[1] = new_two[1] = (y[0] + 1) % n
		new_one[0] = x[0]
		new_two[0] = x[1]
	else:
		new_one = [x[0], y[1]]
		new_two = [x[1], y[0]]
	points.append(new_one)
	points.append(new_two)
	for i in range(n):
		for j in range(n):
			print('*' if [i, j] in points else '.', end='')
		print()

def main():
	t = int(input())
	for _ in range(t):
		solve()
main()


for tc in range(int(input())):
	n = int(input())
	mtr = []
	pt = []
	for i in range(n):
		a = list(input())
		for j in range(n):
			if a[j] == '*':
				pt.append([i, j])
		mtr.append(a)
	output = []
	if pt[0][0] == pt[1][0]:
		if n - pt[0][0] - 1 >= pt[0][0]:
			output = [[n - 1, pt[0][1]], [n - 1, pt[1][1]]]
		else:
			output = [[0, pt[0][1]], [0, pt[1][1]]]
	elif pt[0][1] == pt[1][1]:
		if n - pt[0][1] - 1 >= pt[0][1]:
			output = [[pt[0][0], n - 1], [pt[1][0], n - 1]]
		else:
			output = [[pt[0][0], 0], [pt[1][0], 0]]
	else:
		output = [[pt[0][0], pt[1][1]], [pt[1][0], pt[0][1]]]
	for (i, j) in output:
		mtr[i][j] = '*'
	for i in mtr:
		print(''.join(i))


def main():
	N = int(input())
	S = []
	Coor = []
	for i in range(N):
		s = input()
		S.append(list(s))
		for j in range(N):
			if s[j] == '*':
				Coor.append((i, j))
	(H1, W1) = Coor[0]
	(H2, W2) = Coor[1]
	if H1 == H2:
		if H1 + 1 < N:
			S[H1 + 1][W1] = '*'
			S[H2 + 1][W2] = '*'
		else:
			S[H1 - 1][W1] = '*'
			S[H2 - 1][W2] = '*'
	elif W1 == W2:
		if W1 + 1 < N:
			S[H1][W1 + 1] = '*'
			S[H2][W2 + 1] = '*'
		else:
			S[H1][W1 - 1] = '*'
			S[H2][W2 - 1] = '*'
	else:
		S[H1][W2] = '*'
		S[H2][W1] = '*'
	for i in S:
		print(''.join(i))
T = int(input())
for _ in range(T):
	main()


def solve():
	n = int(input())
	w = []
	for i in range(n):
		q = input()
		if '*' not in q:
			continue
		for j in range(n):
			if q[j] == '*':
				w.append(i)
				w.append(j)
	(ax, ay, bx, by) = w
	(cx, cy, dx, dy) = w
	if ax != bx and ay != by:
		(cx, cy, dx, dy) = (max(ax, bx), max(ay, by), min(ax, bx), min(ay, by))
		if cx == bx and dx == ax and (cy == by) and (dy == ay):
			(cx, cy, dx, dy) = (max(ax, bx), min(ay, by), min(ax, bx), max(ay, by))
	elif ax == bx:
		if ax != 0:
			(cx, cy, dx, dy) = (ax - 1, ay, bx - 1, by)
		else:
			(cx, cy, dx, dy) = (ax + 1, ay, bx + 1, by)
	elif ay == by:
		if ay != 0:
			(cx, cy, dx, dy) = (ax, ay - 1, bx, dy - 1)
		else:
			(cx, cy, dx, dy) = (ax, ay + 1, bx, dy + 1)
	ans = [list('.' * n) for _ in range(n)]
	ans[ax][ay] = '*'
	ans[bx][by] = '*'
	ans[cx][cy] = '*'
	ans[dx][dy] = '*'
	t = []
	for i in ans:
		t.append(''.join(i))
	return '\n'.join(t)
t = int(input())
ans = []
while t:
	ans.append(str(solve()))
	t -= 1
print('\n'.join(ans))


t = int(input())
for i in range(t):
	n = int(input())
	row = list()
	x = list()
	y = list()
	for i in range(n):
		row.append(list(input()))
	for i in range(n):
		for j in range(n):
			if row[i][j] == '*':
				x.append(i)
				y.append(j)
	if x[0] == x[1]:
		if x[0] == 0:
			row[1][y[0]] = '*'
			row[1][y[1]] = '*'
		else:
			row[x[0] - 1][y[0]] = '*'
			row[x[0] - 1][y[1]] = '*'
	elif y[0] == y[1]:
		if y[0] == 0:
			row[x[0]][1] = '*'
			row[x[1]][1] = '*'
		else:
			row[x[0]][y[0] - 1] = '*'
			row[x[1]][y[1] - 1] = '*'
	else:
		row[x[0]][y[1]] = '*'
		row[x[1]][y[0]] = '*'
	for i in range(n):
		for j in range(n):
			print(row[i][j], end='')
		print()


import sys
import math
input = sys.stdin.readline
mod = 10 ** 9 + 7

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
for _ in range(inp()):
	n = inp()
	l = []
	r = -1
	c = -1
	r1 = -1
	c1 = -1
	for i in range(n):
		a = insr()
		l.append(a)
		for j in range(n):
			if a[j] == '*':
				if r == -1:
					r = i
					c = j
					continue
				if r1 == -1:
					r1 = i
					c1 = j
	if r1 == r:
		if r != n - 1:
			l[r + 1][c] = '*'
			l[r1 + 1][c1] = '*'
		else:
			l[r - 1][c] = '*'
			l[r1 - 1][c1] = '*'
	elif c1 == c:
		if c != n - 1:
			l[r][c + 1] = '*'
			l[r1][c + 1] = '*'
		else:
			l[r][c - 1] = '*'
			l[r1][c - 1] = '*'
	else:
		l[r][c1] = '*'
		l[r1][c] = '*'
	for i in range(n):
		print(''.join((j for j in l[i])))


for _ in range(int(input())):
	n = int(input())
	a = 0
	b = 0
	c = 0
	d = 0
	l = []
	for i in range(n):
		l.append(input())
	for i in range(n):
		for j in range(n):
			if l[i][j] == '*' and a == 0:
				a = [i, j]
			elif l[i][j] == '*' and b == 0:
				b = [i, j]
	if a[0] == b[0]:
		if a[0] + 1 < n:
			c = [a[0] + 1, a[1]]
			d = [a[0] + 1, b[1]]
		else:
			c = [a[0] - 1, a[1]]
			d = [a[0] - 1, b[1]]
	elif a[1] == b[1]:
		if a[1] + 1 < n:
			c = [a[0], a[1] + 1]
			d = [b[0], b[1] + 1]
		else:
			c = [a[0], a[1] - 1]
			d = [b[0], b[1] - 1]
	else:
		c = [a[0], b[1]]
		d = [b[0], a[1]]
	for i in range(n):
		s = ''
		for j in range(n):
			if [i, j] in [a, b, c, d]:
				s = s + '*'
			else:
				s = s + '.'
		print(s)


t = int(input())
for T in range(t):
	n = int(input())
	M = ''
	a = -1
	b = -1
	for i in range(n):
		M = M + input()
	for i in range(n ** 2):
		if M[i] == '*':
			if a == -1:
				a = i
			elif b == -1:
				b = i
	A = ['.' for i in range(n ** 2)]
	for i in range(n ** 2):
		if i == a // n * n + b % n or i == b // n * n + a % n or i == a or (i == b) or (i == b // n * n + a % n - 1 + (b % n == 0) * 2 and b % n == a % n) or (i == a // n * n + b % n - 1 + (a % n == 0) * 2 and b % n == a % n) or (i == b // n * n + a % n - n + n * (b // n == 0) * 2 and b // n == a // n) or (i == a // n * n + b % n - n + n * (a // n == 0) * 2 and b // n == a // n):
			A[i] = '*'
	for i in range(n):
		C = ''
		for i in range(i * n, i * n + n):
			C = C + A[i]
		print(C)


for _ in range(int(input())):
	n = int(input())
	a = [list(input()) for _ in range(n)]
	p = []
	for i in range(n):
		for j in range(n):
			if a[i][j] == '*':
				p.append((i, j))
	(h1, w1) = (p[0][0], p[0][1])
	(h2, w2) = (p[1][0], p[1][1])
	if h1 != h2 and w1 != w2:
		a[h2][w1] = '*'
		a[h1][w2] = '*'
	elif h1 == h2 and w1 != w2:
		if h1 == n - 1:
			a[h1 - 1][w1] = '*'
			a[h1 - 1][w2] = '*'
		else:
			a[h1 + 1][w1] = '*'
			a[h1 + 1][w2] = '*'
	elif h1 != h2 and w1 == w2:
		if w1 == n - 1:
			a[h1][w1 - 1] = '*'
			a[h2][w1 - 1] = '*'
		else:
			a[h1][w1 + 1] = '*'
			a[h2][w1 + 1] = '*'
	for aa in a:
		print(''.join(aa))


m = int(input())
u = []
for _ in range(m):
	a = int(input())
	l = []
	for i in range(a):
		l.append(list(input()))
	s = 0
	t = []
	for i in range(a):
		if l[i].count('*') > 0:
			for j in range(a):
				if l[i][j] == '*':
					t.append([i, j])
					s += 1
				if s == 2:
					break
			if s == 2:
				break
	if t[0][1] == t[1][1]:
		if t[0][1] == a - 1:
			l[t[0][0]][t[1][1] - 1] = '*'
			l[t[1][0]][t[0][1] - 1] = '*'
		else:
			l[t[0][0]][t[1][1] + 1] = '*'
			l[t[1][0]][t[0][1] + 1] = '*'
	elif t[0][0] == t[1][0]:
		if t[0][0] == a - 1:
			l[t[0][0] - 1][t[0][1]] = '*'
			l[t[1][0] - 1][t[1][1]] = '*'
		else:
			l[t[0][0] + 1][t[0][1]] = '*'
			l[t[1][0] + 1][t[1][1]] = '*'
	else:
		l[t[0][0]][t[1][1]] = '*'
		l[t[1][0]][t[0][1]] = '*'
	s = ''
	for i in l:
		s += ''.join(i) + '\n'
	u.append(s[:-1])
for i in u:
	print(i)


import sys
n = int(input())
for i in range(n):
	t = int(input())
	minx = 1000000000.0
	maxx = -1
	miny = 1000000000.0
	maxy = -1
	lines = []
	for j in range(t):
		line = input()
		lines.append(list(line))
		for k in range(t):
			if line[k] == '*':
				if j >= maxx:
					maxx = j
				if j <= minx:
					minx = j
				if k >= maxy:
					maxy = k
				if k <= miny:
					miny = k
	if miny == maxy:
		if miny < k - 1:
			maxy = miny + 1
		else:
			miny = miny - 1
	if minx == maxx:
		if minx < k - 1:
			maxx = minx + 1
		else:
			minx = minx - 1
	lines[minx][miny] = '*'
	lines[minx][maxy] = '*'
	lines[maxx][miny] = '*'
	lines[maxx][maxy] = '*'
	for l in lines:
		print(''.join(l))


num_inputs = int(input())
for _ in range(num_inputs):
	n = int(input())
	mat = []
	for __ in range(n):
		mat.append(list(input()))
	edges = []
	for i in range(len(mat)):
		for j in range(len(mat[0])):
			if mat[i][j] == '*':
				edges.append((i, j))
	((x1, y1), (x2, y2)) = edges
	if x1 == x2:
		if x1 + 1 >= len(mat[0]):
			mat[x1 - 1][y1] = '*'
			mat[x1 - 1][y2] = '*'
		else:
			mat[x1 + 1][y1] = '*'
			mat[x1 + 1][y2] = '*'
	elif y1 == y2:
		if y1 + 1 >= len(mat):
			mat[x1][y1 - 1] = '*'
			mat[x2][y1 - 1] = '*'
		else:
			mat[x1][y1 + 1] = '*'
			mat[x2][y1 + 1] = '*'
	else:
		mat[x1][y2] = '*'
		mat[x2][y1] = '*'
	for row in mat:
		print(''.join(row))


from sys import stdin
from collections import Counter
T = int(stdin.readline())
for t in range(T):
	n = int(stdin.readline())
	C = set()
	R = set()
	for i in range(n):
		L = stdin.readline()
		if '*' not in L:
			continue
		C.add(L.index('*'))
		C.add(L.rindex('*'))
		R.add(i)
	if len(R) == 1:
		if next(iter(R)) == 0:
			R.add(1)
		else:
			R.add(0)
	if len(C) == 1:
		if next(iter(C)) == 0:
			C.add(1)
		else:
			C.add(0)
	A = '.' * n
	B = ['.'] * n
	for c in C:
		B[c] = '*'
	B = ''.join(B)
	for i in range(n):
		if i in R:
			print(B)
		else:
			print(A)


for _ in range(int(input())):
	n = int(input())
	l = []
	for i in range(n):
		l.append([x for x in input()])
	lis = []
	for i in range(n):
		for j in range(n):
			if l[i][j] == '*':
				lis.append([i, j])
	u = lis[0][0]
	v = lis[0][1]
	x = lis[1][0]
	y = lis[1][1]
	if u == x:
		if u < n - 2:
			l[u + 1][v] = '*'
			l[u + 1][y] = '*'
		else:
			l[u - 1][v] = '*'
			l[u - 1][y] = '*'
	elif y == v:
		if v < n - 2:
			l[u][v + 1] = '*'
			l[x][y + 1] = '*'
		else:
			l[u][v - 1] = '*'
			l[x][y - 1] = '*'
	else:
		l[u][y] = '*'
		l[x][v] = '*'
	for i in range(n):
		for j in range(n):
			print(l[i][j], end='')
		print()


def arrIn():
	return list(map(int, input().split()))

def mapIn():
	return map(int, input().split())
for ii in range(int(input())):
	n = int(input())
	a = []
	for i in range(n):
		a.append(input())
	(x, y) = ([0, 0], [0, 0])
	flag = True
	for i in range(n):
		for j in range(n):
			if a[i][j] == '*':
				if flag:
					x[0] = i
					y[0] = j
					flag = False
				else:
					x[1] = i
					y[1] = j
					break
	if y[0] == y[1]:
		if y[0] > 0:
			y[0] -= 1
		else:
			y[0] += 1
	if x[0] == x[1]:
		if x[0] > 0:
			x[0] -= 1
		else:
			x[0] += 1
	for i in range(n):
		s = ''
		for j in range(n):
			if (i == x[0] or i == x[1]) and (j == y[0] or j == y[1]):
				s += '*'
			else:
				s += '.'
		print(s)


for t in range(int(input())):
	k = int(input())
	kl = [[i for i in input()] for _ in range(k)]
	x1 = -1
	y1 = -1
	x2 = -1
	y2 = -1
	for i in range(k):
		for j in range(k):
			if kl[i][j] == '*':
				if x1 == -1:
					x1 = i
					y1 = j
				else:
					x2 = i
					y2 = j
	kl[x1][y2] = '*'
	kl[x2][y1] = '*'
	if y1 == y2:
		if y1 != 0:
			kl[x1][0] = '*'
			kl[x2][0] = '*'
		else:
			kl[x1][1] = '*'
			kl[x2][1] = '*'
	elif x1 == x2:
		if x1 != 0:
			kl[0][y1] = '*'
			kl[0][y2] = '*'
		else:
			kl[1][y1] = '*'
			kl[1][y2] = '*'
	for t in kl:
		print(*t, sep='')


def solN():
	n = int(input())
	(p1, p2, p3, p4) = ([], [], [], [])
	for y in range(n):
		r = input()
		for i in range(n):
			if r[i] == '*':
				if p1 == []:
					p1.extend([y, i])
				else:
					p2.extend([y, i])
					break
	if p1[0] == p2[0]:
		if p1[0] == n - 1:
			p3.extend([n - 2, p1[1]])
			p4.extend([n - 2, p2[1]])
		else:
			p3.extend([p1[0] + 1, p1[1]])
			p4.extend([p1[0] + 1, p2[1]])
	elif p1[1] == p2[1]:
		if p1[1] == n - 1:
			p3.extend([p1[0], n - 2])
			p4.extend([p2[0], n - 2])
		else:
			p3.extend([p1[0], p1[1] + 1])
			p4.extend([p2[0], p1[1] + 1])
	else:
		p3.extend([p1[0], p2[1]])
		p4.extend([p2[0], p1[1]])
	for i in range(n):
		for y in range(n):
			if p1[0] == i and p1[1] == y or (p2[0] == i and p2[1] == y) or (p3[0] == i and p3[1] == y) or (p4[0] == i and p4[1] == y):
				print('*', end='')
			else:
				print('.', end='')
		print()

def main():
	for _ in range(int(input())):
		solN()
main()


t = int(input())
while t != 0:
	t -= 1
	n = int(input())
	(x1, y1) = (-1, -1)
	(x2, y2) = (0, 0)
	table = []
	for i in range(n):
		line = list(input())
		for j in range(n):
			if line[j] == '*':
				if x1 == -1:
					x1 = i
					y1 = j
				else:
					x2 = i
					y2 = j
		table.append(line)
	if x1 != x2 and y1 != y2:
		table[x1][y2] = '*'
		table[x2][y1] = '*'
	elif x1 == x2:
		if x1 != n - 1:
			table[x1 + 1][y1] = '*'
			table[x2 + 1][y2] = '*'
		else:
			table[x1 - 1][y1] = '*'
			table[x2 - 1][y2] = '*'
	elif y1 == y2:
		if y1 != n - 1:
			table[x1][y1 + 1] = '*'
			table[x2][y2 + 1] = '*'
		else:
			table[x1][y1 - 1] = '*'
			table[x2][y2 - 1] = '*'
	for i in range(n):
		for j in range(n):
			print(table[i][j], sep='', end='')
		print('')


for t in range(int(input())):
	n = int(input())
	flag = 0
	flag2 = 0
	for i in range(n):
		line = list(map(str, input()))
		if '*' in line:
			if line.count('*') == 1:
				if not flag:
					flag = 1
					str1 = i
					pos1 = line.index('*')
				else:
					str2 = i
					pos2 = line.index('*')
			else:
				str1 = i
				pos1 = line.index('*')
				pos2 = n - 1 - line[::-1].index('*')
				flag2 = 1
	if not flag2:
		if pos1 != pos2:
			line1 = ['.'] * n
			line1[pos1] = '*'
			line1[pos2] = '*'
		elif pos1 == n - 1:
			line1 = ['.'] * n
			line1[pos1 - 1] = '*'
			line1[pos1] = '*'
		else:
			line1 = ['.'] * n
			line1[pos1 + 1] = '*'
			line1[pos1] = '*'
	elif str1 < n - 1:
		str2 = n - 1
		line1 = ['.'] * n
		line1[pos1] = '*'
		line1[pos2] = '*'
	else:
		str1 = n - 2
		line1 = ['.'] * n
		line1[pos1] = '*'
		line1[pos2] = '*'
	for j in range(n):
		if j == str1 or j == str2:
			print(*line1, sep='')
		else:
			print('.' * n)


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	a = [list(input()) for i in range(n)]
	c = [(i, j) for i in range(n) for j in range(n) if a[i][j] == '*']
	if c[0][0] == c[1][0]:
		x1 = c[0][0] + 1
		y1 = c[0][1]
		y2 = c[1][1]
		if c[0][0] == n - 1:
			x1 = c[0][0] - 1
		a[x1][y1] = '*'
		a[x1][y2] = '*'
	elif c[0][1] == c[1][1]:
		y1 = c[0][1] + 1
		x1 = c[0][0]
		x2 = c[1][0]
		if c[0][1] == n - 1:
			y1 = c[0][1] - 1
		a[x1][y1] = '*'
		a[x2][y1] = '*'
	else:
		a[c[0][0]][c[1][1]] = '*'
		a[c[1][0]][c[0][1]] = '*'
	for i in range(n):
		for j in range(n):
			print(a[i][j], end='')
		print()


for _ in range(int(input())):
	n = int(input())
	mat = []
	for i in range(n):
		row = input()
		row = list(row)
		mat.append(row)
	p = []
	for i in range(n):
		for j in range(n):
			if mat[i][j] == '*':
				p.append((i, j))
	if p[0][0] == p[1][0]:
		row = p[0][0]
		col1 = p[0][1]
		col2 = p[1][1]
		if row == n - 1:
			row = row - 1
			mat[row][col1] = '*'
			mat[row][col2] = '*'
		else:
			row = row + 1
			mat[row][col1] = '*'
			mat[row][col2] = '*'
	elif p[0][1] == p[1][1]:
		col = p[0][1]
		row1 = p[0][0]
		row2 = p[1][0]
		if col == n - 1:
			col = col - 1
			mat[row1][col] = '*'
			mat[row2][col] = '*'
		else:
			col = col + 1
			mat[row1][col] = '*'
			mat[row2][col] = '*'
	else:
		row1 = p[0][0]
		col1 = p[0][1]
		row2 = p[1][0]
		col2 = p[1][1]
		mat[row2][col1] = '*'
		mat[row1][col2] = '*'
	for i in range(n):
		v = ''.join(mat[i])
		print(v)


p = int(input())
for i in range(p):
	n = int(input())
	main = []
	row_col = []
	for row in range(n):
		temp = list(input())
		main.append(temp)
		if len(row_col) < 2:
			indexes = [i for (i, x) in enumerate(temp) if x == '*']
			if len(indexes) == 1:
				row_col.append((row, indexes[0]))
			elif len(indexes) == 2:
				row_col = [(row, indexes[0]), (row, indexes[1])]
	if row_col[0][0] == row_col[1][0]:
		new_row = 0 if row_col[0][0] != 0 else 1
		main[new_row][row_col[0][1]] = '*'
		main[new_row][row_col[1][1]] = '*'
	elif row_col[0][1] == row_col[1][1]:
		new_column = 0 if row_col[0][1] != 0 else 1
		main[row_col[0][0]][new_column] = '*'
		main[row_col[1][0]][new_column] = '*'
	else:
		main[row_col[0][0]][row_col[0][1]] = '*'
		main[row_col[0][0]][row_col[1][1]] = '*'
		main[row_col[1][0]][row_col[0][1]] = '*'
		main[row_col[1][0]][row_col[1][1]] = '*'
	for i in main:
		print(''.join(i))


for _ in range(int(input())):
	n = int(input())
	g = []
	c = []
	for i in range(n):
		temp = list(input())
		if '*' in temp:
			c.append([i, temp.index('*')])
			if temp.count('*') == 2:
				c.append([i, temp.index('*', c[0][1] + 1)])
		g.append(temp)
	a = c[0]
	b = c[1]
	if a[0] == b[0]:
		if a[0] < n - 1:
			g[a[0] + 1][a[1]] = '*'
			g[a[0] + 1][b[1]] = '*'
		else:
			g[a[0] - 1][a[1]] = '*'
			g[a[0] - 1][b[1]] = '*'
	elif a[1] == b[1]:
		if a[1] < n - 1:
			g[a[0]][a[1] + 1] = '*'
			g[b[0]][b[1] + 1] = '*'
		else:
			g[a[0]][a[1] - 1] = '*'
			g[b[0]][b[1] - 1] = '*'
	else:
		g[a[0]][b[1]] = '*'
		g[b[0]][a[1]] = '*'
	for i in range(n):
		print(''.join(g[i]))


import sys
input = sys.stdin.readline
for test in range(int(input())):
	n = int(input())
	rows = set()
	columns = set()
	matrix = []
	for test in range(n):
		matrix.append(list(input()[:-1]))
	rows = set()
	columns = set()
	for i in range(n):
		for j in range(n):
			if matrix[i][j] == '*':
				rows.add(i)
				columns.add(j)
	if len(rows) == 1:
		x = list(rows)[0]
		if x + 1 < n:
			rows.add(x + 1)
		else:
			rows.add(x - 1)
	if len(columns) == 1:
		x = list(columns)[0]
		if x + 1 < n:
			columns.add(x + 1)
		else:
			columns.add(x - 1)
	for i in rows:
		for j in columns:
			matrix[i][j] = '*'
	print('\n'.join((''.join(i) for i in matrix)))


n = int(input())
for z in range(n):
	t = int(input())
	x = []
	y = []
	l = [list(str(input())) for _ in range(t)]
	d = {}
	for i in range(t):
		for j in range(t):
			if l[i][j] == '*':
				x.append(i)
				y.append(j)
	k = list(zip(x, y))
	if k[0][0] != k[1][0]:
		if k[0][0] > k[1][0] and k[0][1] != k[1][1]:
			first_x = k[0][0]
			first_y = k[1][1]
			second_x = k[1][0]
			second_y = k[0][1]
		elif k[0][0] < k[1][0] and k[0][1] != k[1][1]:
			first_x = k[1][0]
			first_y = k[0][1]
			second_x = k[0][0]
			second_y = k[1][1]
		if k[0][1] == k[1][1]:
			if l[k[0][0]][-1] == '*':
				first_x = k[0][0]
				first_y = k[0][1] - 1
				second_x = k[1][0]
				second_y = k[1][1] - 1
			else:
				first_x = k[0][0]
				first_y = k[0][1] + 1
				second_x = k[1][0]
				second_y = k[1][1] + 1
	if k[0][0] == k[1][0]:
		if l[0][k[0][1]] == '*':
			first_x = k[0][0] + 1
			first_y = k[0][1]
			second_x = k[1][0] + 1
			second_y = k[1][1]
		else:
			first_x = k[0][0] - 1
			first_y = k[0][1]
			second_x = k[1][0] - 1
			second_y = k[1][1]
	l[first_x][first_y] = '*'
	l[second_x][second_y] = '*'
	for i in range(t):
		print(''.join(l[i]))


t = int(input())
for x in range(t):
	n = int(input())
	a = [list(input()) for i in range(n)]
	c = [(i, j) for i in range(n) for j in range(n) if a[i][j] == '*']
	if c[0][0] == c[1][0]:
		if c[0][0] < n - 1:
			c.append((c[0][0] + 1, c[0][1]))
			c.append((c[0][0] + 1, c[1][1]))
		else:
			c.append((c[0][0] - 1, c[0][1]))
			c.append((c[0][0] - 1, c[1][1]))
	elif c[0][1] == c[1][1]:
		if c[0][1] < n - 1:
			c.append((c[0][0], c[0][1] + 1))
			c.append((c[1][0], c[1][1] + 1))
		else:
			c.append((c[0][0], c[0][1] - 1))
			c.append((c[1][0], c[1][1] - 1))
	else:
		c.append((c[0][0], c[1][1]))
		c.append((c[1][0], c[0][1]))
	for i in range(n):
		for j in range(n):
			if (i, j) in c:
				print('*', end='')
			else:
				print('.', end='')
		print('\n', end='')


t = int(input())
while t > 0:
	n = int(input())
	li = []
	li2 = []
	c = 0
	for x in range(0, n):
		li1 = input()
		li.append(li1)
	for x in range(n):
		st = li[x]
		for y in range(n):
			if st[y] == '*':
				li2.append(x)
				li2.append(y)
				c += 1
			if c == 2:
				break
		if c == 2:
			break
	li3 = []
	if li2[0] == li2[2]:
		if li2[0] == 0:
			li3.append(li2[0] + 1)
			li3.append(li2[1])
			li3.append(li2[0] + 1)
			li3.append(li2[3])
		else:
			li3.append(li2[0] - 1)
			li3.append(li2[1])
			li3.append(li2[0] - 1)
			li3.append(li2[3])
	elif li2[1] == li2[3]:
		if li2[1] == 0:
			li3.append(li2[0])
			li3.append(li2[1] + 1)
			li3.append(li2[2])
			li3.append(li2[1] + 1)
		else:
			li3.append(li2[0])
			li3.append(li2[1] - 1)
			li3.append(li2[2])
			li3.append(li2[1] - 1)
	else:
		li3.append(li2[0])
		li3.append(li2[3])
		li3.append(li2[2])
		li3.append(li2[1])
	for x in range(n):
		for y in range(n):
			if x == li3[0] and y == li3[1]:
				print('*', end='')
			elif x == li3[2] and y == li3[3]:
				print('*', end='')
			else:
				print(li[x][y], end='')
		print()
	t -= 1


for i in range(int(input())):
	n = int(input())
	a = []
	ar = []
	indexes = []
	for p in range(n):
		a = input()
		if '*' in a:
			indexes.append(p)
		ar.append(a)
	indexes_in = []
	for p in indexes:
		for q in range(n):
			if ar[p][q] == '*':
				indexes_in.append(q)
	p1 = []
	p2 = []
	if len(indexes) == 1:
		p1.append((indexes[0] + 1) % n)
		p1.append(indexes_in[0])
		p2.append((indexes[0] + 1) % n)
		p2.append(indexes_in[1])
	elif indexes_in[0] == indexes_in[1]:
		p1.append(indexes[0])
		p1.append((indexes_in[0] + 1) % n)
		p2.append(indexes[1])
		p2.append((indexes_in[1] + 1) % n)
	else:
		p1.append(indexes[0])
		p1.append(indexes_in[1])
		p2.append(indexes[1])
		p2.append(indexes_in[0])
	ar[p1[0]] = ar[p1[0]][:p1[1]] + '*' + ar[p1[0]][p1[1] + 1:]
	ar[p2[0]] = ar[p2[0]][:p2[1]] + '*' + ar[p2[0]][p2[1] + 1:]
	for p in ar:
		print(p)


class Solve:

	def _solve(self):
		n = int(input())
		mp = [input() for _ in range(n)]
		(a, b) = (None, None)
		for i in range(n):
			for (j, symb) in enumerate(mp[i]):
				if symb == '*':
					if not a:
						a = (i, j)
					else:
						b = (i, j)

		def upd_ln(ln, col, s='*'):
			return ln[:col] + s + ln[col + 1:]
		if a[0] == b[0]:
			stri = (a[0] + 1) % n
			mp[stri] = upd_ln(mp[stri], a[1])
			mp[stri] = upd_ln(mp[stri], b[1])
		elif a[1] == b[1]:
			coli = (a[1] + 1) % n
			stri = a[0]
			mp[stri] = upd_ln(mp[stri], coli)
			stri = b[0]
			mp[stri] = upd_ln(mp[stri], coli)
		else:
			stri = a[0]
			coli = b[1]
			mp[stri] = upd_ln(mp[stri], coli)
			stri = b[0]
			coli = a[1]
			mp[stri] = upd_ln(mp[stri], coli)
		print('\n'.join(mp))

	def solve(self):
		t = int(input())
		for i in range(t):
			self._solve()
Solve().solve()


for _ in range(int(input())):
	n = int(input())
	l = []
	for i in range(n):
		l.append(list(input()))
	p = []
	for i in range(n):
		for (j, char) in enumerate(l[i]):
			if char == '*':
				p.append([i, j])
	if p[0][0] == p[1][0]:
		if p[0][0] == 0:
			l[1][p[0][1]] = '*'
			l[1][p[1][1]] = '*'
		else:
			l[0][p[0][1]] = '*'
			l[0][p[1][1]] = '*'
	elif p[0][1] == p[1][1]:
		if p[0][1] == 0:
			l[p[0][0]][1] = '*'
			l[p[1][0]][1] = '*'
		else:
			l[p[0][0]][0] = '*'
			l[p[1][0]][0] = '*'
	else:
		l[p[0][0]][p[1][1]] = '*'
		l[p[1][0]][p[0][1]] = '*'
	for k in l:
		print(''.join(k))


while True:
	try:
		t = eval(input())
		for i in range(t):
			n = eval(input())
			list0 = []
			list1 = []
			for j in range(n):
				list0.append(list(input()))
				for k in range(n):
					if list0[j][k] == '*':
						list1.append(j)
						list1.append(k)
			if list1[0] == list1[2]:
				if list1[0] == 0:
					list1[0] = list1[2] = 1
				else:
					list1[0] = list1[2] = 0
			elif list1[1] == list1[3]:
				if list1[1] == 0:
					list1[1] = list1[3] = 1
				else:
					list1[1] = list1[3] = 0
			list0[list1[0]][list1[3]] = '*'
			list0[list1[2]][list1[1]] = '*'
			for j in range(n):
				print(''.join(list0[j]), end='\n')
	except:
		break


q = int(input())
for i in range(q):
	x = int(input())
	a = []
	for i in range(x):
		a.append(list(input()))
	b = []
	for i in range(x):
		for j in range(x):
			if a[i][j] == '*':
				b.append([i, j])
	if b[0][0] == b[1][0]:
		if b[0][0] + 1 < x:
			a[b[0][0] + 1][b[0][1]] = '*'
		else:
			a[b[0][0] - 1][b[0][1]] = '*'
		if b[1][0] + 1 < x:
			a[b[1][0] + 1][b[1][1]] = '*'
		else:
			a[b[1][0] - 1][b[1][1]] = '*'
	elif b[0][1] == b[1][1]:
		if b[0][1] + 1 < x:
			a[b[0][0]][b[0][1] + 1] = '*'
		else:
			a[b[0][0]][b[0][1] - 1] = '*'
		if b[1][1] + 1 < x:
			a[b[1][0]][b[1][1] + 1] = '*'
		else:
			a[b[1][0]][b[1][1] - 1] = '*'
	else:
		a[b[0][0]][b[1][1]] = '*'
		a[b[1][0]][b[0][1]] = '*'
	for i in range(x):
		print(''.join(a[i]))


import sys
import math
import collections
t = int(input())
for w in range(t):
	n = int(input())
	l = []
	for i in range(n):
		l.append(list(input()))
	c = 0
	for i in range(n):
		for j in range(n):
			if l[i][j] == '*':
				if c == 0:
					c += 1
					t1 = (i, j)
				else:
					c += 1
					t2 = (i, j)
					break
		if c == 2:
			break
	if t1[0] == t2[0]:
		if t1[0] == n - 1:
			(l[t1[0] - 1][t1[1]], l[t2[0] - 1][t2[1]]) = ('*', '*')
		else:
			(l[t1[0] + 1][t1[1]], l[t2[0] + 1][t2[1]]) = ('*', '*')
	elif t1[1] == t2[1]:
		if t1[1] == n - 1:
			(l[t1[0]][t1[1] - 1], l[t2[0]][t2[1] - 1]) = ('*', '*')
		else:
			(l[t1[0]][t1[1] + 1], l[t2[0]][t2[1] + 1]) = ('*', '*')
	else:
		(l[t1[0]][t2[1]], l[t2[0]][t1[1]]) = ('*', '*')
	for i in range(n):
		print(''.join(l[i]))