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