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