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

long long base = 257, mod = 1000000007;
string s;
int n;
string nec[100002];
unordered_set <long long> lengths, codes;
long long pr[100002], st[100005];
vector <long long> lens;

int main () {
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);

cin >> s;
cin >> n;

for (int i=0; i < n; i++) {
    cin >> nec[i];
    lengths.insert(nec[i].size());
    long long x=0;
    for (int j=0; j < nec[i].size(); j++) {
        x = (x*base + int(nec[i][j]))%mod;
    }
    codes.insert(x);
    //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;
}

st[0] = 1;
for (int i=1; i <= 100003; i++) {
    st[i] = (base*st[i-1])%mod;
}
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;
        if (i == 0) {k == 0;}
        else {k = pr[i-1];}
        long long curr = (pr[i + lens[j] - 1] + mod - ((k*st[lens[j]])%mod))%mod;
        if (codes.find(curr) != codes.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;
}