#include<iostream>

using namespace std;

const int MAX = 1e5 + 3;

string words[MAX], s;

int n;

string rem_str_from_str(string in, int s, int e)
{
    string out = "";
    for(int i = 0;i < in.size();i++)
        if(i < s || i >= e)
            out += in[i];
    return out;
}

int main()
{
    cin.tie(0);

    cin  >> s;
    cin  >> n;

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

    for(int i = 0, index = 0;i < s.size();i++)
    {
        for(int j = 0;j < n;j++)
        {
            index = 0;
            int word_size = words[j].size(), tmp_i = i;

            while(s[tmp_i] == words[j][index])
            {
                tmp_i ++;
                index++;
                if(index == word_size)
                {
                    s = rem_str_from_str(s, i, tmp_i);
                    i = -1;
                    goto label;
                }
            }
        }
        label:;
    }

    cout << s << "\n";

    return 0;
}
