#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
string s, s1;
int n, m, p, bra = 0; // m - s.size; p - s1
pair<int,int> callme[100003];
int main()
{
    cin >> s;
    cin >> n;
    s = s + " ";
    for(int i = 0; i < n; i ++)
    {
        cin >> s1;
        m = s.size();
        p = 0;
        for(int j = 0; j < m; j ++)
        {
            if(p == s1.size())
            {
                //s.erase(j-p,p);
                //j -= p;
                //m -= p;
                bra ++;
                callme[bra].first = j-p;
                callme[bra].second = p;
                p = 0;
            }
            if(s1[p] == s[j])
            {
                p ++;
            }
            else if(s1[p] != s[j]) p = 0;
        }
    }
    ///sort(callme.begin(), callme.end());
    for(int i=1; i < bra; i ++)
    {
        for(int j=i+1; j <= bra; j ++)
        {
            if(callme[i].first < callme[j].first) swap(callme[i], callme[j]);
        }
    }

    for(int i=1; i <= bra; i ++)
    {
        s.erase(callme[i].first, callme[i].second);
    }
    cout << s << endl;
    return 0;
}
/*
cppcodingenjoycppcodingcppprogramscoding
3
code
coding
cpp
*/
