#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
string s, s1;
int n, m, p; // m - s.size; p - s1
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;
                p = 0;
            }
            if(s1[p] == s[j])
            {
                p ++;
            }
            else if(s1[p] != s[j]) p = 0;
        }
    }
    cout << s << endl;
    return 0;
}
/*
cppcodingenjoycppcodingcppprogramscoding
3
code
coding
cpp
*/
