#include <iostream>
#include <string>
#include <vector>
#include <set>
using namespace std;
template<class T>
void myprint(T first,T last){
last--;
for(;first!=last;first++){cout<<*first<<",";}
cout<<*first<<endl;
}
class myless{
public:
bool operator () (const string &a,const string &b){
for(int i=0;i<a.size()&&i<b.size();i++){
if(a[i]<b[i]) return true;
else if (a[i]>b[i])return false;
}
if(a.size()<b.size()) return true;
else return false;
}
};
int main()
{
string ss;
multiset<string,myless> s;
while(getline(cin,ss))
{
string re="";
for(char a:ss)
{
if(a==',') {s.insert(re);re="";continue;}
re+=a;
}
s.insert(re);re="";
myprint(s.begin(),s.end());
//cout<<endl;
s.clear();
}
}
#include <string>
#include <vector>
#include <set>
using namespace std;
template<class T>
void myprint(T first,T last){
last--;
for(;first!=last;first++){cout<<*first<<",";}
cout<<*first<<endl;
}
class myless{
public:
bool operator () (const string &a,const string &b){
for(int i=0;i<a.size()&&i<b.size();i++){
if(a[i]<b[i]) return true;
else if (a[i]>b[i])return false;
}
if(a.size()<b.size()) return true;
else return false;
}
};
int main()
{
string ss;
multiset<string,myless> s;
while(getline(cin,ss))
{
string re="";
for(char a:ss)
{
if(a==',') {s.insert(re);re="";continue;}
re+=a;
}
s.insert(re);re="";
myprint(s.begin(),s.end());
//cout<<endl;
s.clear();
}
}