#include <iostream>
#include <cstring>
using namespace std;
int main () {
    string a,b[1000];
    int n;
    getline(cin,a);
    cin>>n;
    int sm=a.size(),m;
    for(int i=0;i<n;i++) {
        cin>>b[i];
        int x=a.find(b[i]);
        if(x>=0 and x<=sm) {
            while(x>=0 and x<=sm) {
            a=a.erase(x,b[i].size());
            x=a.find(b[i]);
        }
        }
    }
    cout<<a<<endl;
    return 0;
}
