#include <iostream>
#include <string>
using namespace std;

void remove(string& s, string& sub) {
    int l = sub.length();
    for (int j = 0; j <= s.length() - l; j++) {
        string curr = s.substr(j, l);
        if (curr == sub)
            s.erase(j, l);
    }
    return;
}

int main() {
    string s, curr, sub;
    int n, i, j;
    int len, l;
    cin >> s;
    cin >> n;
    len = s.length();
    for (i = 0; i < n; i++) {
        cin >> curr;
        remove(s, curr);
    }
    cout << s << endl;
    return 0;
}