#include <cstdio> #include <iostream> #include <string> #include <cstdio> using namespace std; int main() { int i, j, T, pos; char B[1005], c; string X; while(scanf("%d %s", &T, B) != EOF) { X = B; for (i=0; i<T; ++i) { pos = 0; while ((c = getchar()) != '\n') { if (c == X.at(pos)) ++pos; else { if (pos != 0) { for(j=0; j<pos; ++j) putchar(X.at(j)); pos = 0; } if (c == X.at(pos)) ++pos; else putchar(c); } if (X.size() == pos) pos = 0; } putchar('\n'); } } return 0; }