#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define PI acos(-1)
#define sz 10020
#define mod 10000007
#define RUN_FAST ios::sync_with_stdio(false);
using namespace std;

//int row[]={0, 0, -1, 1};///4 adjacent(Up, down, left, right)
//int col[]={1, -1, 0, 0};

//int row[]={-2, -2, 2, 2, -1, -1, 1, 1};///Knight moves on
//int col[]={1, -1, 1, -1, 2, -2, 2, -2};///chess board

int main()
{
    RUN_FAST; cin.tie(nullptr);
    int T, n, i, j, r1, c1, r2, c2;
    vector <string> v;
    vector <pair <int, int>> pos;
    string s;
    cin >> T;
    while (T--) {
        cin >> n;
        for (i=0; i<n; i++) {
            cin >> s;
            v.push_back(s);
        }
        for (i=0; i<n; i++) {
            for (j=0; j<n; j++)
                if (v[i][j]=='*') pos.push_back({i, j});
        }
        r1=pos[0].first, c1=pos[0].second;
        r2=pos[1].first, c2=pos[1].second;

        if (r1==r2) {
            if (r1==0) v[r1+1][c1]=v[r1+1][c2]='*';
            else v[r1-1][c1]=v[r1-1][c2]='*';
        }
        else if (c1==c2) {
            if (c1==0) v[r1][c1+1]=v[r2][c1+1]='*';
            else v[r1][c1-1]=v[r2][c1-1]='*';
        }
        else v[r1][c2]=v[r2][c1]='*';
        for (string ss: v) cout << ss << endl;
        v.clear();
        pos.clear();
    }
    return 0;
}
