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

string str[100000];

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

        }
    }
    return;
}

int main() {
    string s;
    int n, i, j;
    int len, l;
    cin >> s >> n;
    len = s.length();
    for (i = 0; i < n; i++)
        cin >> str[i];
    sort(str, str + n,
         [](string s1, string s2) {
            return s1.length() >= s2.length();
         });
    for (i = 0; i < n; i++)
        remove(s, str[i]);
    cout << s << endl;
    return 0;
}