#include<iostream>
#include<sstream>
#include<vector>
#include<cctype>
using namespace std;
int main(){
    string line;
    getline(cin,line);
    string word;
    vector<string>ordered(101);
    int maxpos=0;
    while(ss>>word){
        int pos=-1;
        for (char c:word){
            if (c=='-'){
                cout<<"Invalid input";
                return 0;
            }
            if(isdigit(c)){
                pos=c-'0';
            }
        }
        if(pos==-1) continue;
        string clean ="";
        for(char c:word)
        if(!isdigit(c))
        clean+=c;
        ordered[pos] =clean;
        if(pos>maxpos)
        maxpos=pos;
    }
    for (int i=0; i<=maxpos; i++){
        if(!ordered[i].empty()){
            cout<<ordered[i];
            if(i<maxpos)cout<<" ";
        }
    }
    return 0;
}