#include <bits/stdc++.h>
using namespace std;
    string a, b;
    vector <long long> er, erl;
    long long n, m, p;
int main (){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
    long long i, j;
    cin >> a;
    n=a.length();
    cin >> m;
    for (i=0; i<m; i++){
        cin >> b;
        p=a.find(b);
        while (p!=string::npos){
            er.push_back(p);
            erl.push_back(b.size());
//            a.erase(p, b.size());
            p=a.find(b, p+b.size());
        }
    }
    n=er.size();
    for (i=0; i<n; i++){
        a.erase(er[i], erl[i]);
    }
    cout << a << endl;
return 0;
}
