#include
using namespace std;
const int maxn = 200009;
int n, tn, tr[maxn][26], ed[maxn], fl[maxn]; int m, pi[maxn], dl[maxn], r[maxn]; char a[maxn], g[maxn];
void trieIns(char* i) { int p(1), l(0); for (; *i; ++ i, ++ l) { int t(*i - 97); if (!tr[p][t]) { tr[p][t] = ++ tn; ed[tn] = 0; memset(tr[tn], 0, sizeof(tr[tn])); } p = tr[p][t]; } ed[p] = l; }
void acaBuild() { static int q[maxn]; int hd(0), tl(1); q[0] = 1; while (hd < tl) { int u(q[hd ++]); for (int i = 0; i < 26; ++ i) if (tr[u][i]) { int v(tr[u][i]), w; for (w = fl[u]; w && !tr[w][i]; w = fl[w]); if (!w) fl[v] = 1; else fl[v] = tr[w][i]; q[tl ++] = v; } else tr[u][i] = tr[fl[u]][i]; } }
int getTrans(int p, int w) { for (; p && !tr[p][w]; p = fl[p]); return p ? tr[p][w] : 1; }
int getRoot(int x) { register int p, q; for (p = r[x]; p ^ r[p]; p = r[p]); for (; x ^ p; q = r[x], r[x] = p, x = q); return x; }
int main() { #ifndef ONLINE_JUDGE freopen(".in", “r”, stdin); freopen(".o1", “w”, stdout); #endif
scanf("%s%d", a + 1, &n);
m = strlen(a + 1);
for (int i = 1; i <= m; ++ i)
r[i] = i;
tn = 1;
memset(tr[1], 0, sizeof(tr[1]));
ed[1] = 0;
for (int i = 0; i < n; ++ i) {
scanf("%s", g);
trieIns(g);
}
acaBuild();
pi[0] = 1;
for (int i = 1; i <= m; ++ i) {
pi[i] = getTrans(pi[getRoot(i - 1)], a[i] - 97);
if (ed[pi[i]]) {
int le(ed[pi[i]]), p(i);
for (int j = 0; j < le; ++ j) {
r[p] = getRoot(p - 1);
p = r[p];
}
pi[i] = pi[p];
}
}
for (int i = 1; i <= m; ++ i)
if (r[i] == i)
putchar(a[i]);
putchar(10);
}