#include <bits/stdc++.h>
using namespace std;
#define fr(i,l,r) for(i=l;i<r;i++)
#define fr0(i,r) fr(i,0,r)
#define ll long long 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define pob pop_back
#define mp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define all(x) x.begin(),x.end()
#define YES cout<<"YES\n"
#define NO cout<<"NO\n";
// std::vector<ll> cnt;
// std::vector<ll> vis;
// std::vector<ll> vec;

ll power(ll x, ll y)  
{  
    ll temp;  
    if(y == 0)  
        return 1ll;  
    temp = power(x, y / 2);  
    if (y % 2 == 0)  
        return temp * temp;  
    else
    {  
            return x * temp * temp;  
    }  
} 
int binomialCoeff(int n, int k) 
{ 
    int C[n + 1][k + 1]; 
    int i, j; 
  
    // Caculate value of Binomial Coefficient 
    // in bottom up manner 
    for (i = 0; i <= n; i++) 
    { 
        for (j = 0; j <= min(i, k); j++) 
        { 
            // Base Cases 
            if (j == 0 || j == i) 
                C[i][j] = 1; 
  
            // Calculate value using previously 
            // stored values 
            else
                C[i][j] = C[i - 1][j - 1] + 
                          C[i - 1][j]; 
        } 
    } 
  
    return C[n][k]; 
} 
bool sortbysec(pair<ll,ll> a, pair<ll,ll> b){
    return a.ss<b.ss;
}

typedef struct{
    ll left;
    ll right;
    ll up;
    ll down;
}geo;

string printLCSubStr(string X, string Y, int m, int n)
{
    // Create a table to store lengths of longest common
    // suffixes of substrings.   Note that LCSuff[i][j]
    // contains length of longest common suffix of X[0..i-1]
    // and Y[0..j-1]. The first row and first column entries
    // have no logical meaning, they are used only for
    // simplicity of program
    int LCSuff[m + 1][n + 1];
 
    // To store length of the longest common substring
    int len = 0;
 
    // To store the index of the cell which contains the
    // maximum value. This cell's index helps in building
    // up the longest common substring from right to left.
    int row, col;
 
    /* Following steps build LCSuff[m+1][n+1] in bottom
       up fashion. */
    for (int i = 0; i <= m; i++) {
        for (int j = 0; j <= n; j++) {
            if (i == 0 || j == 0)
                LCSuff[i][j] = 0;
 
            else if (X[i - 1] == Y[j - 1]) {
                LCSuff[i][j] = LCSuff[i - 1][j - 1] + 1;
                if (len < LCSuff[i][j]) {
                    len = LCSuff[i][j];
                    row = i;
                    col = j;
                }
            }
            else
                LCSuff[i][j] = 0;
        }
    }
 
    // if true, then no common substring exists
    if (len == 0) {
        //cout << "No Common Substring";
        string fg="";
        return fg;
    }
 
    // allocate space for the longest common substring
    string resultStr;
 resultStr.resize(len);
    // traverse up diagonally form the (row, col) cell
    // until LCSuff[row][col] != 0
    while (LCSuff[row][col] != 0) {
        resultStr[--len] = X[row - 1]; // or Y[col-1]
 
        // move diagonally up to previous cell
        row--;
        col--;
    }
 
    // required longest common substring
    return resultStr;
}
int search(string pat, string txt)
{
    //cout<<"pat="<<pat<<" text="<<txt<<"\n";
    int M = pat.size();
    int N =txt.size();
    //cout<<"M="<<M<<" N="<<N<<"\n";
int i = 0; 
    /* A loop to slide pat[] one by one */
    while (i <= N - M) {
        int j;

        /* For current index i, check for pattern match */
        for (j = 0; j < M; j++)
            if (txt[i + j] != pat[j])
                break;
  
        if (j == M) // if pat[0...M-1] = txt[i, i+1, ...i+M-1]
            { //cout<<i<<"\n\n";  
        return i;}
      i++;
    }
    return -1;
}
void reverse(vector<int>& v, int i, int j)
{   
    int n=v.size();
    for(int k=0; k<(j-i+1)/2; k++){
        swap(v[i+k],v[j-k]);
    }
}
int main(){
    IOS;
    ll t,n,m,i,j,k,l,x,y,a,b,c,r;
    cin>>t;
    while(t--){
        cin>>n;
        char arr[n][n]; int flg=0;
        fr0(i,n){
            fr0(j,n) {cin>>arr[i][j]; if(arr[i][j]=='*') {if(flg==0){ a=i; b=j; flg=1; } else {x=i;  y=j;}} }

        }
        int a1,a2,a3,a4;
        if(b==y){
            if(b==n-1) { a4=a2=n-2;}
            else a4=a2=b+1;
            a1=a;  a3=x;
        }
        else{
            if(a==x){
            if(a==n-1) { a1=a3=n-2;}
            else a1=a3=a+1;
            a2=b;  a4=y;
            }
            else{
                a1=a; a2=y;
                a3=x;  a4=b;
            }
        }
        arr[a1][a2]='*';  arr[a3][a4]='*';
        fr0(i,n){
            fr0(j,n) cout<<arr[i][j];
            cout<<"\n";
        }

    }
}
 