#include <bits/stdc++.h>
using namespace std;
int main()
{
    string c;
    cin >> c;
    long long n;
    cin >> n;
    string bad;
    for(int i = 0; i < n; i++) {
        cin >> bad;
        int p;
        while((p = c.find(bad)) != string::npos) {
            cout << p << endl;
            c.erase(p, bad.size());
        }
    }
    cout << c;



    return 0;
}
