#include <bits/stdc++.h>

using namespace std;

int t,s;
struct p{
    int x;
    int y;
};
struct a{
    int s;
    p pos[4];
};
char ch;
a zip[405];

int main(){
    cin>>t;
    for(int times=0;times<t;times++){
        cin>>zip[times].s;
        int k=0,flag=1;
        for(int i=1;i<=zip[times].s;i++){
            for(int j=1;j<=zip[times].s;j++){
                cin>>ch;
                if(ch=='*'){
                        zip[times].pos[k].x=i;
                        zip[times].pos[k].y=j;
                        k++;
                }
            }
        }
        if(zip[times].pos[0].x==zip[times].pos[1].x){
            if(zip[times].pos[0].x<zip[times].s){
                zip[times].pos[2].x=zip[times].pos[0].x+1;
                zip[times].pos[3].x=zip[times].pos[0].x+1;
                zip[times].pos[2].y=zip[times].pos[0].y;
                zip[times].pos[3].y=zip[times].pos[1].y;
            }
            else if(zip[times].pos[0].x>1){
                zip[times].pos[2].x=zip[times].pos[0].x-1;
                zip[times].pos[3].x=zip[times].pos[0].x-1;
                zip[times].pos[2].y=zip[times].pos[0].y;
                zip[times].pos[3].y=zip[times].pos[1].y;
            }
        }
        else if(zip[times].pos[0].y==zip[times].pos[1].y){
            if(zip[times].pos[0].y<zip[times].s){
                zip[times].pos[2].y=zip[times].pos[0].y+1;
                zip[times].pos[3].y=zip[times].pos[0].y+1;
                zip[times].pos[2].x=zip[times].pos[0].x;
                zip[times].pos[3].x=zip[times].pos[1].x;
            }
            else if(zip[times].pos[0].y>1){
                zip[times].pos[2].y=zip[times].pos[0].y-1;
                zip[times].pos[3].y=zip[times].pos[0].y-1;
                zip[times].pos[2].x=zip[times].pos[0].x;
                zip[times].pos[3].x=zip[times].pos[1].x;
            }
        }
        else {
            zip[times].pos[2].y=zip[times].pos[0].y;
            zip[times].pos[3].y=zip[times].pos[1].y;
            zip[times].pos[2].x=zip[times].pos[1].x;
            zip[times].pos[3].x=zip[times].pos[0].x;
        }


    }

    for(int times=0;times<t;times++){
            int flag[405][405]={0};
            for(int k=0;k<4;k++){
                flag[zip[times].pos[k].x][zip[times].pos[k].y]=1;
            }
        for(int i=1;i<=zip[times].s;i++){
            for(int j=1;j<=zip[times].s;j++){

                 if(flag[i][j])printf("*");
                 else printf(".");
            }
            printf("\n");
        }
    }
    return 0;
}

	 	 						     		  		 				 	