#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

bool cmp(string a, string b)
{
    return a.size() > b.size();
}

int main ()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    string s;
    cin >> s;
    int sz = s.size();

    int n;
    cin >> n;

    vector <string> v(n);

    for (int i = 0; i < n; i++)
        cin >> v[i];

//    sort(v.begin(), v.end(), cmp);

    for (int i = 0; i < n; i++)
    {
        string p = v[i];

        while (true)
        {
            int ind = s.find(p);
            if (ind == -1) break;
            s.erase(s.begin() + ind, s.begin() + ind + p.size());
        }
//        cerr << ind << endl;
    }

    cout << s << endl;

    return 0;
}
/***
enjoycodingcppprograms
3
code
coding
cpp

-----
enjoyprograms
*/
