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

    string s;
    cin >> s;
    long long n;
    cin >> n;
    long long bad_word_hash[n];
    long long power[n];
    long long sz[n];
    for(long long 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;
        }
    }
    long long word_hash[n];
    for(long long i = 0; i < n; i++) {
        word_hash[i] = 0;
    }
    bool is_bad[s.size()];
    for(long long i = 0; i < s.size(); i++) {
        is_bad[i] = false;
    }
    for(long long t = 0; t < s.size(); t++) {
        char c = s[t];
        for(long long 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]) % mod;
                word_hash[i] %= mod;
            }

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

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




    return 0;
}
