#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 9;
const long long base = 1009;
int main() {

    string s;
    cin >> s;
    int n;
    cin >> n;
    long long bad_word_hash[n];
    long long power[n];
    long long sz[n];
    for(int t = 0; t < n; t++) {
        string word;
        cin >> word;
        sz[t] = word.size();
        bad_word_hash[t] = 0;
        power[t] = 1;
        for(auto c : word) {
            bad_word_hash[t] *= base;
            bad_word_hash[t] += c;
            bad_word_hash[t] %= mod;
            power[t] *= base;
            power[t] %= mod;
        }
        //cout << bad_word_hash[t] << endl;
    }
    long long word_hash[n];
    for(int i = 0; i < n; i++) {
        word_hash[i] = 0;
    }
    //vector<pair<int, int>> bad_word_index();
    bool  is_bad[s.size()];
    for(int t = 0; t < s.size(); t++) {
        char c = s[t];
        for(int i = 0; i < n; i++) {
            word_hash[i] *= base;
            word_hash[i] += c;
            word_hash[i] %= mod;
            if(t >= sz[i]) {
                word_hash[i] += mod * mod;
                word_hash[i] -= s[t - sz[i]] * power[i];
                word_hash[i] %= mod;
                //cout << word_hash[i] << endl;
            }

            if(word_hash[i] == bad_word_hash[i]) {
                for(int j = t - sz[i] + 1; j <= t; j++) {
                    is_bad[j] = true;
                }
            }
        }
    }

    for(int i = 0; i < s.size(); i++) {
        if(!is_bad[i]) {
            cout << s[i];
        }
    }
    cout << endl;




    return 0;
}
