#include<iostream>
#include<sstream>
#include<vector>
#include<cctype>
using namespace std;
int main(){
    string l;
    detline(cin,l);
    stringstream ss(l)
    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(isdegit(c)){
                pos=c-'0';
            }
        }
        if(pos==-1)continue;
        string clean ="";
        for(char c:word)
        if(!isdegit(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;
        }
}