#include<bits/stdc++.h>

using namespace std;

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define forn(i,n)       for(ll i=0;i<ll(n);i++)

typedef long long ll;
typedef long double ld;

const int INF=int(1e9);
const ll INF64=ll(1e18);
const ld EPS=1e-9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

// c(n,k)
void Divbygcd(ll& a,ll& b){ll g=gcd(a,b);a/=g;b/=g;}
ll C(ll n,ll k){ll numerator=1,denominator=1,toMul,toDiv,i;if (k>n/2) k=n-k;for (i=k;i;i--){toMul=n-k+i;toDiv=i;
Divbygcd(toMul,toDiv);Divbygcd(numerator,toDiv);Divbygcd(toMul,denominator);numerator*=toMul;denominator*=toDiv;}return numerator/denominator;}
// end

//fast pow
ll square(ll n) { return n*n; }

ll fast_pow(ll base,ll power){if (power == 0)return 1;else if (power%2 == 0)return square(fast_pow(base,power/2));else return base * (fast_pow(base,power-1));}
//end

bool isPrime(ll n){if(n==1)return false;else if(n==2) return true;else if(n%2==0)return false;else for(ll i=3;i*i<=n;i+=2) if(n%i==0)return false;return true;}
//If 2^N modulo N = 2 then N has a high probability to be a prime number.

//  Sieve prime generator algorithm between L and U
void sieve(ll L,ll U){ll i,j,d;d=U-L+1;bool *flag=new bool[d];for (i=0;i<d;i++) flag[i]=true;for (i=(L%2!=0);i<d;i+=2) flag[i]=false;for (i=3;i<=sqrt(U);i+=2) {if (i>L && !flag[i-L]) continue;j=L/i*i; if (j<L) j+=i;if (j==i) j+=i;j-=L;for (;j<d;j+=i) flag[j]=false;}if (L<=1) flag[1-L]=false;if (L<=2) flag[2-L]=true;for (i=0;i<d;i++) if (flag[i]) cout << (L+i) << " ";cout << endl;}
//end

ll sum_num(ll num){ll ans=0,d=10;while(num){ans+=(num%d);num/=10;}return ans;}

ll LCM (ll m,ll n) {return (m * n) / gcd (m,n);}

//compare
//int compare_function(const void *a,const void *b){int *x = (int *) a;int *y = (int *) b;return *x - *y;}
//int compare_function(const void *a,const void *b) {return (strcmp((char *)a,(char *)b));}
//int compare_function(const void *a,const void *b){double *x = (double *) a;double *y = (double *) b;if (*x < *y) return -1;else if (*x > *y) return 1; return 0;}

/*
typedef struct {
int day,month,year;
char *name;
} birthday;
int compare_function(const void *a,const void *b) {
birthday *x = (birthday *) a;
birthday *y = (birthday *) b;
if (x->month != y->month) // months different
return x->month - y->month; // sort by month
else { // months equal..., try the 2nd field... day
if (x->day != y->day) // days different
return x->day - y->day; // sort by day
else // days equal, try the 3rd field... year
return x->year - y->year; // sort by year
}
}
*/

//end compare

char arr[401][401],memo[1000000];

bool flag=0;

ll t,n,m,a,b,c,i,j,sm,k1,l1,k2,l2,mn=1000000001,mx=0;


void read()
{
   fast;
   cin>>t;
   while(t--)
   {
       cin>>n;
       sm=0;
       for(i=0;i<n;i++)
        for(j=0;j<n;j++)
       {
           cin>>arr[i][j];
           if(arr[i][j]=='*' && sm==0)
           {
               sm++;
               k1=i;
               l1=j;
           }
           else if(arr[i][j]=='*' && sm==1)
           {
               k2=i;
               l2=j;
           }

       }
       if(k1==k2 && k1!=n-1)
       {
           arr[k1+1][l1]='*';
           arr[k2+1][l2]='*';
       }
       if(k1==k2 && k1==n-1)
       {
           arr[k1-1][l1]='*';
           arr[k2-1][l2]='*';
       }
       if(l1==l2 && l1!=n-1)
       {
           arr[k1][l1+1]='*';
           arr[k2][l2+1]='*';
       }
       if(l1==l2 && l1==n-1)
       {
           arr[k1][l1-1]='*';
           arr[k2][l2-1]='*';
       }
       if(k1!=k2 && l1!=l2)
       {
           arr[k1][l2]='*';
           arr[k2][l1]='*';
       }
       for(i=0;i<n;i++)
       {
           for(j=0;j<n;j++)
                cout<<arr[i][j];
        cout<<endl;
       }

       //cout<<k1<<"    "<<l1<<"     "<<k2<<"  "<<l2<<"      ";
   }

}

void solve()
{

}

int main()
{
    read();
    solve();
    return 0;
}
