#include <bits/stdc++.h>
using namespace std;
int main()
{
    string c;
    cin >> c;
    long long n;
    cin >> n;
    string bad;
    for(int i = 0; i < n; i++) {
        cin >> bad;
        int p;
        if((p = c.find(bad)) != string::npos) {
            c.erase(p, bad.size());
        }
    }
    cout << c;



    return 0;
}
