#include <bits/stdc++.h>
using namespace std;

long long base = 257, mod = 1000000007;
long long base1 = 257, mod1 = 1000000009;
long long base2 = 257, mod2 = 1000000021;
string s;
int n;
string nec[100002];
unordered_set <long long> lengths, codes, codes1, codes2;
long long pr[100002], st[100005], st1[100005], pr1[100002], st2[100005], pr2[100002];
vector <long long> lens;

int main () {

cin >> s;
cin >> n;

for (int i=0; i < n; i++) {
    cin >> nec[i];
    lengths.insert(nec[i].size());
    long long x=0, y=0, z=0;
    for (int j=0; j < nec[i].size(); j++) {
        x = (x*base + int(nec[i][j]))%mod;
        y = (y*base1 + 2*int(nec[i][j]))%mod1;
        z = (z*base2 + int(nec[i][j]))%mod2;
    }
    codes.insert(x);
    codes1.insert(y);
    codes2.insert(z);
    //cout << i << " " << x << endl;
}

for (auto it = lengths.begin(); it != lengths.end(); it++) {
    lens.push_back(*it);
    //cout << *it << endl;
}

pr[0] = int (s[0]);
//cout << pr[0] << endl;
for (int i=1; i < s.size(); i++) {
    pr[i] = (pr[i-1]*base + int (s[i]))%mod;
    //cout << i << " " << pr[i] << endl;
}

pr1[0] = 2*int (s[0]);
for (int i=1; i < s.size(); i++) {
    pr1[i] = (pr1[i-1]*base1 + 2*int(s[i]))%mod1;
}

pr2[0] = int (s[0]);
for (int i=1; i < s.size(); i++) {
    pr2[i] = (pr2[i-1]*base2 + int(s[i]))%mod2;
}

st[0] = 1;
for (int i=1; i <= 100003; i++) {
    st[i] = (base*st[i-1])%mod;
}
st1[0] = 1;
for (int i=1; i <= 100003; i++) {
    st1[i] = (base1*st1[i-1])%mod1;
}
st2[0] = 1;
for (int i=1; i <= 100003; i++) {
    st2[i] = (base2*st2[i-1])%mod2;
}
string answer = "";
for (int i=0; i < s.size(); i++) {
    //cout << i;
    bool ima=false;
    for (int j=0; j < lens.size(); j++) {
        if (i + lens[j] - 1 >= s.size()) {continue;}
        long long k, k1, k2;
        if (i == 0) {k == 0; k1 = 0; k2=0;}
        else {k = pr[i-1]; k1 = pr1[i-1]; k2 = pr2[i-1];}
        long long curr = (pr[i + lens[j] - 1] + mod - ((k*st[lens[j]])%mod))%mod;
        long long curr1 = (pr1[i + lens[j] - 1] + mod1 - ((k1*st1[lens[j]])%mod1))%mod1;
        long long curr2 = (pr2[i + lens[j] - 1] + mod2 - ((k2*st2[lens[j]])%mod2))%mod2;
        if (codes.find(curr) != codes.end() and codes1.find(curr1) != codes1.end() and codes2.find(curr2) != codes2.end()) {
            i = i + lens[j] - 1;
            ima = true;
            break;
        }
    }
    //cout << " " << ima << " " << i << endl;
    if (ima == false) {answer = answer + s[i];}
}

cout << answer << endl;

return 0;
}