#include #include #include #include #include #include using namespace std; #define REP(i,n) for(int i = 0;i<(n);i++) typedef long long LL; char in[2000][2000]; char tmp[2000][2000]; char cipher[2000][2000]; char text[4000000]; void rotate(int n) { REP(i,n) REP(j,n) { tmp[i][j] = in[n-j-1][i]; } REP(i,n) REP(j,n) in[i][j] = tmp[i][j]; } bool solve(){ int n; scanf("%d", &n); if (n == 0) return false; REP(i,n) { scanf("%s", in[i]); } REP(i,n) { scanf("%s", cipher[i]); } int pos = 0; REP(k,4) { REP(i,n) REP(j,n) { if (in[i][j]=='O') { text[pos] = cipher[i][j]; pos++; } } rotate(n); } text[pos]='\0'; printf("%s\n", text); return true; } main(){ while(1){ if(!solve()) break; } return 0; }