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

const int MAXN = 100005;
bool erased[100005];
string s;
string v[MAXN];
int s_size = 0;

int fast_find(string p)
{
    int p_size = p.size();
    for (int i = 0; i < s_size; i++)
    {
        int start_i = i;
        int j = 0;
        while (i < s_size && j < p_size && s[i] == p[j] && !erased[i])
        {
            i++;
            j++;
        }
        if (j == p_size) return start_i;
    }
    return -1;
}

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


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

    int n;
    cin >> n;

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

    while (true)
    {
        int mini = 2e9;
        int minind = 0;
        for (int i = n - 1; i >= 0; i--)
        {
            int ind = fast_find(v[i]);
            if (ind == -1) continue;
            if (ind < mini)
            {
                minind = i;
                mini = ind;
            }
        }
        if (mini != 2e9)
        {
            int to = mini + v[minind].size();
            for (int i = mini; i < to; i++)
                erased[i] = true;
        }
        else break;
    }

    for (int i = 0; i < s_size; i++)
    {
        if (!erased[i]) cout << s[i];
    }
    cout << endl;

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

-----
enjoyprograms
*/
