#include <bits/stdc++.h>
using namespace std;
void solve()
{
	int n;cin >> n;
	vector<string> input(n);
	pair<int, int> p1 = {-1, -1}, p2 = {-1, -1};
	for (int i = 0 ;i < n ;i++)
	{
		cin >> input[i];
		for (int j = 0 ; j < n ; j++)
		{
			string row = input[i];
			if ( row[j] == '*' )
			{
				if (p1.first == -1) p1 = {i, j};
				else p2 = {i, j};
			}
		}
	}

	if (p1.first != p2.first && p1.second != p2.second)
	{
		input[p2.first][p1.second] = '*';
		input[p1.first][p2.second] = '*';
	}else if (p1.first != p2.first && p1.second == p2.second)
	{
		input[p1.first][(p1.second + 1) % n] = '*';
		input[p2.first][(p1.second + 1) % n] = '*';
	}else
	{
		input[(p1.first + 1) % n][p1.second] = '*';
		input[(p1.first + 1) % n][p2.second] = '*';
	}
	for (int i = 0 ; i < n ; i++) cout << input[i] << endl;

}
int main(int argc, char const *argv[])
{
	int t;cin >> t;
	while(t--) solve();
	return 0;
}