#include <bits/stdc++.h>
using namespace std;
typedef int ll;
ll n;
char a[15][15], b[15][15];
set <char> r[15], c[15];
map <pair<ll,ll>, set <char>> cannot;
void solve(ll x, ll y);
ll f=0;
char temp;
int i=0;
ll leftgret=0, leftsmal=0, upgret=0, upsmal=0;
void backtrack(ll x, ll y)
{
if (b[x][y]!='-')
{
if (y==1)
{
backtrack(x-2, 2*n-1);
}
else
{
backtrack(x, y-2);
}
}
else
{
temp=a[x][y];
leftgret=0, leftsmal=0, upgret=0, upsmal=0;
if (y>=1&&a[x][y-1]=='>')
{
leftgret=1;
}
if (y>=1&&a[x][y-1]=='<')
{
leftsmal=1;
}
if (x>=1&&a[x-1][y]=='v')
{
upgret=1;
}
if (x>=1&&a[x-1][y]=='^')
{
upsmal=1;
}
f=0;
for (i = 49; i <49+n ; ++i)
{
if (cannot[{x,y}].find(i) == cannot[{x,y}].end() && r[x].find(i)!=r[x].end()&&c[y].find(i)!=c[y].end()&&((leftgret&&i<a[x][y-2])||!leftgret)&&(!leftsmal||(leftsmal&&i>a[x][y-2]))&&(!upgret||(upgret&&i<a[x-2][y]))&&(!upsmal||(upsmal&&i>a[x-2][y])))
{
f=1;
a[x][y]=i;
r[x].erase(i);
c[y].erase(i);
r[x].insert(temp);
c[y].insert(temp);
cannot[{x, y}].insert(i);
break;
}
}
if (!f)
{
r[x].insert(temp);
c[y].insert(temp);
while(!cannot[{x, y}].empty())
{
cannot[{x, y}].erase(cannot[{x, y}].begin());
}
if (y==1)
{
backtrack(x-2, 2*n-1);
}
else
{
backtrack(x, y-2);
}
}
else
{
// while(!cannot[{x, y}].empty())
// {
// cannot[{x, y}].erase(cannot[{x, y}].begin());
// }
if (y==2*n-1)
{
solve(x+2, 1);
}
else
{
solve(x, y+2);
}
}
}
return;
}
void solve(ll x, ll y)
{
if (x>2*n-1||y>2*n-1)
{
return;
}
if (b[x][y]=='-')
{
leftgret=0, leftsmal=0, upgret=0, upsmal=0;
if (y>=1&&a[x][y-1]=='>')
{
leftgret=1;
}
if (y>=1&&a[x][y-1]=='<')
{
leftsmal=1;
}
if (x>=1&&a[x-1][y]=='v')
{
upgret=1;
}
if (x>=1&&a[x-1][y]=='^')
{
upsmal=1;
}
f=0;
for (i = 49; i <49+n ; ++i)
{
if (r[x].find(i)!=r[x].end()&&c[y].find(i)!=c[y].end()&&((leftgret&&i<a[x][y-2])||!leftgret)&&(!leftsmal||(leftsmal&&i>a[x][y-2]))&&(!upgret||(upgret&&i<a[x-2][y]))&&(!upsmal||(upsmal&&i>a[x-2][y])))
{
f=1;
a[x][y]=i;
r[x].erase(i);
c[y].erase(i);
break;
}
}
if (!f)
{
if (y==1)
{
backtrack(x-2, 2*n-1);
}
else
{
backtrack(x, y-2);
}
}
else
{
if (y==2*n-1)
{
solve(x+2, 1);
}
else
{
solve(x, y+2);
}
}
}
else
{
leftgret=0, leftsmal=0, upgret=0, upsmal=0, f=0;
if (y>=1&&a[x][y-1]=='>')
{
leftgret=1;
}
if (y>=1&&a[x][y-1]=='<')
{
leftsmal=1;
}
if (x>=1&&a[x-1][y]=='v')
{
upgret=1;
}
if (x>=1&&a[x-1][y]=='^')
{
upsmal=1;
}
if (((leftgret&&b[x][y]<a[x][y-2])||!leftgret)&&(!leftsmal||(leftsmal&&b[x][y]>a[x][y-2]))&&(!upgret||(upgret&&b[x][y]<a[x-2][y]))&&(!upsmal||(upsmal&&b[x][y]>a[x-2][y])))
{
f=1;
}
if (!f)
{
if (y==1)
{
backtrack(x-2, 2*n-1);
}
else
{
backtrack(x, y-2);
}
}
else
{
if (y==2*n-1)
{
solve(x+2, 1);
}
else
{
solve(x, y+2);
}
}
}
return;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
for (int i = 1; i < 2*n; ++i)
{
for (int j = 49; j < n+49; ++j)
{
r[i].insert(j);
c[i].insert(j);
}
}
for (int i = 1; i < 2*n; ++i)
{
for (int j = 1; j < 2*n; ++j)
{
cin >> a[i][j];
b[i][j]=a[i][j];
if (a[i][j]<49+n&&a[i][j]>48)
{
cannot[{i,j}].insert(a[i][j]);
r[i].erase(r[i].find(a[i][j]));
c[j].erase(c[j].find(a[i][j]));
}
}
}
solve(1,1);
for(ll i=1; i<2*n; i++)
{
while(!r[i].empty())
{
r[i].erase(r[i].begin());
}
while(!c[i].empty())
{
c[i].erase(c[i].begin());
}
}
for(ll i=0; i<2*n; i++)
{
for(ll j=0; j<2*n; j++)
{
while(!cannot[{i,j}].empty())
{
cannot[{i,j}].erase(cannot[{i,j}].begin());
}
}
}
for (int i = 1; i < 2*n; i+=2)
{
for (int j = 1; j < 2*n; j+=2)
{
cout << a[i][j];
}
cout <<"\n";
}
// cout << flag;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CnR5cGVkZWYgaW50IGxsOwpsbCBuOwpjaGFyIGFbMTVdWzE1XSwgYlsxNV1bMTVdOwpzZXQgPGNoYXI+IHJbMTVdLCBjWzE1XTsgCm1hcCA8cGFpcjxsbCxsbD4sIHNldCA8Y2hhcj4+IGNhbm5vdDsKdm9pZCBzb2x2ZShsbCB4LCBsbCB5KTsKbGwgZj0wOwpjaGFyIHRlbXA7CmludCBpPTA7CmxsIGxlZnRncmV0PTAsIGxlZnRzbWFsPTAsIHVwZ3JldD0wLCB1cHNtYWw9MDsKdm9pZCBiYWNrdHJhY2sobGwgeCwgbGwgeSkKewoKCWlmIChiW3hdW3ldIT0nLScpCgl7CgkJaWYgKHk9PTEpCgkJewoJCQliYWNrdHJhY2soeC0yLCAyKm4tMSk7CgkJfQoJCWVsc2UKCQl7CgkJCWJhY2t0cmFjayh4LCB5LTIpOwoJCX0KCX0KCWVsc2UKCXsKCQl0ZW1wPWFbeF1beV07CgkJbGVmdGdyZXQ9MCwgbGVmdHNtYWw9MCwgdXBncmV0PTAsIHVwc21hbD0wOwkJCgkJaWYgKHk+PTEmJmFbeF1beS0xXT09Jz4nKQoJCXsKCQkJbGVmdGdyZX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gaSsrKQogICAgewogICAgCXdoaWxlKCFyW2ldLmVtcHR5KCkpCiAgICAJewogICAgCQlyW2ldLmVyYXNlKHJbaV0uYmVnaW4oKSk7CiAgICAJfQoKICAgIAl3aGlsZSghY1tpXS5lbXB0eSgpKQogICAgCXsKICAgIAkJY1tpXS5lcmFzZShjW2ldLmJlZ2luKCkpOwogICAgCX0KICAgIH0KCiAgICBmb3IobGwgaT0wOyBpPDIqbjsgaSsrKQogICAgewogICAgCWZvcihsbCBqPTA7IGo8MipuOyBqKyspCiAgICAJewogICAgCQl3aGlsZSghY2Fubm90W3tpLGp9XS5lbXB0eSgpKQogICAgCQl7CiAgICAJCQljYW5ub3Rbe2ksan1dLmVyYXNlKGNhbm5vdFt7aSxqfV0uYmVnaW4oKSk7CiAgICAJCX0KICAgIAl9CiAgICB9CiAgICBmb3IgKGludCBpID0gMTsgaSA8IDIqbjsgaSs9MikKICAgIHsKICAgIAlmb3IgKGludCBqID0gMTsgaiA8IDIqbjsgais9MikKICAgIAl7CiAgICAJCWNvdXQgPDwgYVtpXVtqXTsKICAgIAl9CiAgICAJY291dCA8PCJcbiI7CiAgICB9CgogICAgLy8gY291dCA8PCBmbGFnOwogICAgcmV0dXJuIDA7Cn0=