#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);

    while (!v.empty())
    {
        int mini = 2e9;
        int minind = 0;
        for (int i = v.size() - 1; i >= 0; i--)
        {
            int ind = s.find(v[i]);
            if (ind == -1)
            {
                v.erase(v.begin() + i, v.begin() + i + 1);
                continue;
            }
            if (ind < mini)
            {
                minind = i;
                mini = ind;
            }
        }
        if (mini != 2e9) s.erase(s.begin() + mini, s.begin() + mini + v[minind].size());
        else break;
    }

    cout << s << endl;

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

-----
enjoyprograms
*/
