#include <iostream>
#include <string>
#include <fstream>
using namespace std;

#define in cin
#define out cout
//ifstream in("4441.txt");
//ofstream out("4441out.txt");

int main()
{
    int pos;
    char sep;
    string vacia(80, ' ');
    string str = vacia, texto, c;
    while (in >> c)
    {
        if (c == "!")
        {
            out << str << endl;
            str = vacia;
        }
        else
        {
            pos = atoi(c.c_str())-1;
            in >> sep;
            getline(in, texto, sep);
            str.replace(pos, texto.length(), texto, 0, 80-pos);
        }
    }

    return 0;
}

