#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <stdlib.h>
using namespace std;
bool isInteger(const std::string & s)
{
   if(s.empty() || ((!isdigit(s[0])) && (s[0] != '-') && (s[0] != '+'))) return false ;

   char * p ;
   strtol(s.c_str(), &p, 10) ;

   return (*p == 0) ;
}
int main() {
        // Open our file
        ifstream inFile("inputfile.txt",ifstream::in);

        // If we can read/write great
        std::vector<string> strVector;
        std::vector<string> outVector;
        string str;
        int num;
        int code;
        bool trueCode = false;
        //if (inFile.good()) {
            while(cin>>str){
                strVector.push_back(str);
            }
            vector<string>::iterator it=  strVector.begin();;
            bool preIsInt = true;//0:number, 1:str
            while(it != strVector.end()) {
                bool isInt = isInteger(*it);
                if(isInt){
                    int n_of_code = atoi((*it).c_str());
                    outVector.push_back((*it));
                    it++;
                    while(n_of_code) {
                        outVector.push_back(" ");
                        outVector.push_back((*it));
                        if(!isInteger(*it)){
                            n_of_code--;
                        }
                        it++;
                    }
                    if((it+1)==strVector.end()||isInteger(*(it+1))){
                        outVector.push_back(" ");
                        outVector.push_back((*it));
                        it++;
                    }
                    outVector.push_back("\n");
                }
            }
            for(it=outVector.begin();it!=outVector.end();it++) {
                cout<<(*it);
            }
          //  inFile.close();
        //}
        //system("pause");
        return 0;
}
