#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char a[28] = "";
char b[28] = "";
char c[28] = "";
int count;
int step;
int N;
int hehe;
void search(int m, int n){
int i;
if(count == N){
return ;
}
for(i = m; i < n; i++){
if(b[i] == a[step]){
step--;
count++;
break;
}
}
if(i == n){
return ;
}
search(i + 1, n);
search(m, i);
c[hehe++] = b[i];
}
int main()
{
int i;
while(1){
count = 0;
hehe = 0;
scanf("%d", &N);
getchar();
memset(a, 0, sizeof(a));
memset(b, 0, sizeof(b));
memset(c, 0, sizeof(c));
gets(b);
gets(a);
step = N - 1;
search(0, N);
for(i = count - 1; i >= 0; i--){
printf("%c", c[i]);
}
}
return 0;
}
#include<stdlib.h>
#include<string.h>
char a[28] = "";
char b[28] = "";
char c[28] = "";
int count;
int step;
int N;
int hehe;
void search(int m, int n){
int i;
if(count == N){
return ;
}
for(i = m; i < n; i++){
if(b[i] == a[step]){
step--;
count++;
break;
}
}
if(i == n){
return ;
}
search(i + 1, n);
search(m, i);
c[hehe++] = b[i];
}
int main()
{
int i;
while(1){
count = 0;
hehe = 0;
scanf("%d", &N);
getchar();
memset(a, 0, sizeof(a));
memset(b, 0, sizeof(b));
memset(c, 0, sizeof(c));
gets(b);
gets(a);
step = N - 1;
search(0, N);
for(i = count - 1; i >= 0; i--){
printf("%c", c[i]);
}
}
return 0;
}