#include<iostream>
using namespace std;
int main(){
string s;
cin>>s;
int n;
cin>>n;
string words[n];
for(int i=0;i<n;i++){
    cin>>words[i];
    for(int j=0;j<s.size();j++){
        if(words[i][0]==s[j]){
            //cout<<s[j]<<"\n";
            string temp=s;
            s[j]='*';
            for(int p=1;p<words[i].size();p++){

                if(words[i][p]!=s[j+p]){
                    s=temp;
                    break;
                }else{
                    s[j+p]='*';
                    //cout<<s<<"\n";
                }
            }
        }
    }
}
string mutated_string="";
for(int j=0;j<s.size();j++){
    if(s[j]!='*'){
        mutated_string+=s[j];
    }
}
cout<<mutated_string<<endl;
/*
for(int i=0;i<s.size();i++){
    cout<<s[i]<<"\n";
}
*/
return 0;
}
