#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define fi first
#define se second
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,m,n) for(int i=m;i<n;i++)
#define fe(i,n) for(int i=n-1;i>=0;i--)
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define qii queue<int>
#define pb push_back

const int N=1e5+1;
const int MOD=1e9+7;

vi ar(200001);
int n;

vi take(int n){
    vi a(n);
    f(i,n)cin>>a[i];
    return a;
}

template<typename p>
p power(p a,p n){
    p ans = 1;
    while(n){
        if(n&1)ans *= a;
        a = a * a;
        n >>= 1;
    }
    return ans;
}

template<typename p>
p mpower(p a,p n){
    p ans = 1;
    while(n){
        if(n&1)ans = (ans*a)%MOD;
        a = (a * a)%MOD;
        n >>= 1;
    }
    return ans;
}

int dfs(int x,int pv,vector<vi>& v){
    if(v[x].size()==1&&v[x][0]==pv){ar[x]=n-1;return 1;}
    int an = 1;
    for(int y:v[x]){
        if(y==pv)continue;
        int tp = dfs(y,x,v);
        an += tp;
        ar[x] = max(ar[x],tp);
    }
    ar[x] = max(ar[x],n-an);
    return an;
}

int dp1[1000][1000];
int dp2[1000][1000];



int fn(int k,int i,int bn){
    if(k==0)return 0;
    if(k==1)return 1;
    if(bn==0&&dp1[k][i]!=-1)return dp1[k][i];
    if(bn==1&&dp2[k][i]!=-1)return dp2[k][i];

    if(bn){
            int temp = 0;
        for(int j=i+1;j<n;j++){
            temp = (temp+fn(k-1,j,0))%MOD;
        }
            return dp2[k][i] = (1+temp)%MOD;
    }
    else{
        int temp = 0;
        for(int j=i-1;j>=0;j--){
            temp = (temp+fn(k-1,j,1))%MOD;
        }
            return dp1[k][i] = (1+temp)%MOD;
    }
}

void solve(){
    int m;
    cin>>m;
    vector<vector<char>> a(m);
    char x;
    int k=-1,l,p,q;
    f(i,m){f(j,m){cin>>x;a[i].pb(x);if(x=='*'&&k==-1){k=i;l=j;}else if(x=='*'){p=i;q=j;}}}
    if(k==p){
        if(k+1<m){
            a[k+1][l] = a[k+1][q] = '*';
        } else {
            a[k-1][l] = a[k-1][q] = '*';
        }
    }
    else if(l==q){
        if(l+1<m){
            a[k][l+1] = a[p][l+1] = '*';
        } else {
            a[k][l-1] = a[p][q-1] = '*';
        }
    } else {
        a[k][q] = a[p][l] = '*';
    }
    f(i,m){{f(j,m)cout<<a[i][j];}cout<<endl;}
}




int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;cin>>t;

    while(t--){
            solve();
    }
}

