#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
int n;
char arr[100][100];
int g[100][100];
char brr[]={'y','i','z','h','o','n','g'};
int dx[]={-1,-1,0,1,1,1,0,-1};
int dy[]={0,1,1,1,0,-1,-1,-1};
typedef pair<int,int>PII;
queue<PII>q;
int ans=0;
int temp;
void dfs(int x,int y,int count)
{
for(int i=0;i<8;i++)
{
int a=x+dx[i];
int b=y+dy[i];
if(a<1||b<1||b>n||a>n)continue;
if(count+1==1&&arr[a][b]=='i')
{
temp=i;
q.push({a,b});
dfs(a,b,count+1);
}
else if(count+1>=2&&count+1<6)
{
if(arr[a][b]==brr[count+1]&&i==temp)
{
q.push({a,b});
dfs(a,b,count+1);
}
}
else if(arr[a][b]=='g'&&count==5&&temp==i)
{
q.push({a,b});
while(q.size())
{
PII t=q.front();
g[t.first][t.second]=1;
q.pop();
}
return;
}
}
while(q.size())
{
q.pop();
}
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
cin>>arr[i][j];
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
if(arr[i][j]=='y')
{
q.push({i,j});
dfs(i,j,0);
}
}
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
if(g[i][j]==1)
{
cout<<arr[i][j];
}
else cout<<'*';
}
cout<<endl;
}
return 0;
}