#include<bits/stdc++.h>
using namespace std;
string a,b,c;
int maxx,mid,low,br;
int main(){

 cin>>a>>b>>c;
 if(a.size()>=b.size() and a.size()>=c.size() and b.size()>=c.size()) {maxx=a.size();mid=b.size();low=c.size() ;}
 if(b.size()>=a.size() and b.size()>=c.size() and a.size()>=c.size())  {maxx=b.size();mid=a.size();low=c.size() ;}
 if(c.size()>=a.size() and c.size()>=b.size() and a.size()>=b.size())  {maxx=c.size();mid=a.size();low=b.size() ;}
 if(a.size()>=b.size() and a.size()>=c.size() and b.size()<=c.size())  {maxx=a.size();mid=c.size();low=b.size() ;}
 if(b.size()>=a.size() and b.size()>=c.size() and c.size()>=a.size())  {maxx=b.size();mid=c.size();low=a.size() ;}
 if(c.size()>=a.size() and c.size()>=b.size() and b.size()>=a.size())  {maxx=c.size();mid=b.size();low=a.size() ;}
 //cout<<low<<" "<<mid<<" "<<maxx;
 if(a==b and b==c) {cout<<a<<b<<c;return 0;}

if(a.size()==b.size() and b.size()==c.size()) {
 for(int i=0;i<maxx;i++){
   if(a[i]>b[i] and a[i]>c[i] and b[i]>c[i]) { cout<<a<<b<<c;return 0;}
   if(a[i]>b[i] and a[i]>c[i] and c[i]>b[i]) { cout<<a<<c<<b;return 0;}
   if(b[i]>a[i] and b[i]>c[i] and a[i]>c[i]) { cout<<b<<a<<c;return 0;}
   if(b[i]>a[i] and b[i]>c[i] and c[i]>a[i]) { cout<<b<<c<<a;return 0;}
   if(c[i]>b[i] and c[i]>a[i] and a[i]>b[i]) { cout<<c<<a<<b;return 0;}
   if(c[i]>b[i] and c[i]>a[i] and b[i]>a[i]) { cout<<c<<b<<a;return 0;}

   if(a[i]>b[i] and a[i]>c[i] and b[i]==c[i]) {
      for(int j=i;j<min(b.size(),c.size());j++){
        if(b[j]>c[j]) {cout<<a<<b<<c;return 0;}
        if(b[j]<c[j]) {cout<<a<<c<<b;return 0;}
      }
      if(b.size()<=c.size() and c[b.size()]>=c[0]) { cout<<a<<c<<b; return 0;}
      if(b.size()<=c.size() and c[b.size()]<=c[0]) { cout<<a<<b<<c; return 0;}
      if(c.size()<=b.size() and b[c.size()]>=b[0]) { cout<<a<<b<<c; return 0;}
      if(c.size()<=b.size() and b[c.size()]<=b[0]) { cout<<a<<c<<b; return 0;}

   }
   if(b[i]>a[i] and b[i]>c[i] and a[i]==c[i]) {
      for(int j=i;j<min(a.size(),c.size());j++){
        if(a[j]>c[j]) {cout<<b<<a<<c;return 0;}
        if(a[j]<c[j]) {cout<<b<<c<<a;return 0;}
      }
      if(a.size()<=c.size() and c[a.size()]>=c[0]) { cout<<b<<c<<a; return 0;}
      if(a.size()<=c.size() and c[a.size()]<=c[0]) { cout<<b<<a<<c; return 0;}
      if(c.size()<=a.size() and a[c.size()]>=a[0]) { cout<<b<<a<<c; return 0;}
      if(c.size()<=a.size() and a[c.size()]<=a[0]) { cout<<b<<c<<a; return 0;}
   }
    if(c[i]>b[i] and c[i]>a[i] and b[i]==a[i]) {
      for(int j=i;j<min(b.size(),a.size());j++){
        if(b[j]>a[j]) {cout<<c<<b<<a;return 0;}
        if(b[j]<a[j]) {cout<<c<<a<<b;return 0;}
      }
      if(a.size()<=b.size() and b[a.size()]>=b[0]) { cout<<c<<b<<a; return 0;}
      if(a.size()<=b.size() and b[a.size()]<=b[0]) { cout<<c<<a<<b; return 0;}
      if(b.size()<=a.size() and a[b.size()]>=a[0]) { cout<<c<<a<<b; return 0;}
      if(b.size()<=a.size() and a[b.size()]<=a[0]) { cout<<c<<b<<a; return 0;}
   }


   if(a[i]<b[i] and a[i]<c[i] and b[i]==c[i]) {
      for(int j=i;j<min(b.size(),c.size());j++){
        if(b[j]>c[j]) {cout<<b<<c<<a;return 0;}
        if(b[j]<c[j]) {cout<<c<<b<<a;return 0;}
      }
      if(b.size()<=c.size() and c[b.size()]>=c[0]) { cout<<c<<b<<a; return 0;}
      if(b.size()<=c.size() and c[b.size()]<=c[0]) { cout<<b<<c<<a; return 0;}
      if(c.size()<=b.size() and b[c.size()]>=b[0]) { cout<<b<<c<<a; return 0;}
      if(c.size()<=b.size() and b[c.size()]<=b[0]) { cout<<c<<b<<a; return 0;}
   }
    if(b[i]<a[i] and b[i]<c[i] and a[i]==c[i]) {
      for(int j=i;j<min(a.size(),b.size());j++){
        if(a[j]>c[j]) {cout<<a<<c<<b;return 0;}
        if(a[j]<c[j]) {cout<<c<<a<<b;return 0;}
      }
      if(a.size()<=c.size() and c[a.size()]>=c[0]) { cout<<c<<a<<b; return 0;}
      if(a.size()<=c.size() and c[a.size()]<=c[0]) { cout<<a<<c<<b; return 0;}
      if(c.size()<=a.size() and a[c.size()]>=a[0]) { cout<<a<<c<<b; return 0;}
      if(c.size()<=a.size() and a[c.size()]<=a[0]) { cout<<c<<a<<b; return 0;}
   }
    if(c[i]<a[i] and c[i]<b[i] and a[i]==b[i]) {
      for(int j=i;j<min(a.size(),b.size());j++){
        if(b[j]>a[j]) {cout<<b<<a<<c;return 0;}
        if(b[j]<a[j]) {cout<<a<<b<<c;return 0;}
      }
      if(a.size()<=b.size() and b[a.size()]>=b[0]) { cout<<b<<a<<c; return 0;}
      if(a.size()<=b.size() and b[a.size()]<=b[0]) { cout<<a<<b<<c; return 0;}
      if(b.size()<=a.size() and a[b.size()]>=a[0]) { cout<<a<<b<<a; return 0;}
      if(b.size()<=a.size() and a[b.size()]<=a[0]) { cout<<b<<a<<c; return 0;}
   }

   } }






   for(int i=0;i<low;i++){
   if(a[i]>b[i] and a[i]>c[i] and b[i]>c[i]) { cout<<a<<b<<c;return 0;}
   if(a[i]>b[i] and a[i]>c[i] and c[i]>b[i]) { cout<<a<<c<<b;return 0;}
   if(b[i]>a[i] and b[i]>c[i] and a[i]>c[i]) { cout<<b<<a<<c;return 0;}
   if(b[i]>a[i] and b[i]>c[i] and c[i]>a[i]) { cout<<b<<c<<a;return 0;}
   if(c[i]>b[i] and c[i]>a[i] and a[i]>b[i]) { cout<<c<<a<<b;return 0;}
   if(c[i]>b[i] and c[i]>a[i] and b[i]>a[i]) { cout<<c<<b<<a;return 0;}

   if(a[i]>b[i] and a[i]>c[i] and b[i]==c[i]) {
      for(int j=i;j<min(b.size(),c.size());j++){
        if(b[j]>c[j]) {cout<<a<<b<<c;return 0;}
        if(b[j]<c[j]) {cout<<a<<c<<b;return 0;}
      }
      if(b.size()<=c.size() and c[b.size()]>=c[0]) { cout<<a<<c<<b; return 0;}
      if(b.size()<=c.size() and c[b.size()]<=c[0]) { cout<<a<<b<<c; return 0;}
      if(c.size()<=b.size() and b[c.size()]>=b[0]) { cout<<a<<b<<c; return 0;}
      if(c.size()<=b.size() and b[c.size()]<=b[0]) { cout<<a<<c<<b; return 0;}

   }
   if(b[i]>a[i] and b[i]>c[i] and a[i]==c[i]) {
      for(int j=i;j<min(a.size(),c.size());j++){
        if(a[j]>c[j]) {cout<<b<<a<<c;return 0;}
        if(a[j]<c[j]) {cout<<b<<c<<a;return 0;}
      }
      if(a.size()<=c.size() and c[a.size()]>=c[0]) { cout<<b<<c<<a; return 0;}
      if(a.size()<=c.size() and c[a.size()]<=c[0]) { cout<<b<<a<<c; return 0;}
      if(c.size()<=a.size() and a[c.size()]>=a[0]) { cout<<b<<a<<c; return 0;}
      if(c.size()<=a.size() and a[c.size()]<=a[0]) { cout<<b<<c<<a; return 0;}
   }
    if(c[i]>b[i] and c[i]>a[i] and b[i]==a[i]) {
      for(int j=i;j<min(b.size(),a.size());j++){
        if(b[j]>a[j]) {cout<<c<<b<<a;return 0;}
        if(b[j]<a[j]) {cout<<c<<a<<b;return 0;}
      }
      if(a.size()<=b.size() and b[a.size()]>=b[0]) { cout<<c<<b<<a; return 0;}
      if(a.size()<=b.size() and b[a.size()]<=b[0]) { cout<<c<<a<<b; return 0;}
      if(b.size()<=a.size() and a[b.size()]>=a[0]) { cout<<c<<a<<b; return 0;}
      if(b.size()<=a.size() and a[b.size()]<=a[0]) { cout<<c<<b<<a; return 0;}
   }


   if(a[i]<b[i] and a[i]<c[i] and b[i]==c[i]) {
      for(int j=i;j<min(b.size(),c.size());j++){
        if(b[j]>c[j]) {cout<<b<<c<<a;return 0;}
        if(b[j]<c[j]) {cout<<c<<b<<a;return 0;}
      }
      if(b.size()<=c.size() and c[b.size()]>=c[0]) { cout<<c<<b<<a; return 0;}
      if(b.size()<=c.size() and c[b.size()]<=c[0]) { cout<<b<<c<<a; return 0;}
      if(c.size()<=b.size() and b[c.size()]>=b[0]) { cout<<b<<c<<a; return 0;}
      if(c.size()<=b.size() and b[c.size()]<=b[0]) { cout<<c<<b<<a; return 0;}
   }
    if(b[i]<a[i] and b[i]<c[i] and a[i]==c[i]) {
      for(int j=i;j<min(a.size(),b.size());j++){
        if(a[j]>c[j]) {cout<<a<<c<<b;return 0;}
        if(a[j]<c[j]) {cout<<c<<a<<b;return 0;}
      }
      if(a.size()<=c.size() and c[a.size()]>=c[0]) { cout<<c<<a<<b; return 0;}
      if(a.size()<=c.size() and c[a.size()]<=c[0]) { cout<<a<<c<<b; return 0;}
      if(c.size()<=a.size() and a[c.size()]>=a[0]) { cout<<a<<c<<b; return 0;}
      if(c.size()<=a.size() and a[c.size()]<=a[0]) { cout<<c<<a<<b; return 0;}
   }
    if(c[i]<a[i] and c[i]<b[i] and a[i]==b[i]) {
      for(int j=i;j<min(a.size(),b.size());j++){
        if(b[j]>a[j]) {cout<<b<<a<<c;return 0;}
        if(b[j]<a[j]) {cout<<a<<b<<c;return 0;}
      }
      if(a.size()<=b.size() and b[a.size()]>=b[0]) { cout<<b<<a<<c; return 0;}
      if(a.size()<=b.size() and b[a.size()]<=b[0]) { cout<<a<<b<<c; return 0;}
      if(b.size()<=a.size() and a[b.size()]>=a[0]) { cout<<a<<b<<a; return 0;}
      if(b.size()<=a.size() and a[b.size()]<=a[0]) { cout<<b<<a<<c; return 0;}
   }

   }


  if(a.size()!=b.size() and b.size()!=c.size() and a.size()!=c.size()) {
   for(int i=low;i<mid;i++){
     if(low==a.size() and mid==b.size()){
        if(b[i]>c[i] and b[low]>=b[0] and c[low]>=c[0]) {cout<<b<<c<<a;return 0;}
        if(b[i]>c[i] and b[low]>=b[0] and c[low]<=c[0]) {cout<<b<<a<<c;return 0;}
        if(b[i]>c[i] and b[low]<=b[0] and c[low]<=c[0]) {cout<<a<<b<<c;return 0;}
        if(b[i]<c[i] and b[low]>=b[0] and c[low]>=c[0]) {cout<<c<<b<<a;return 0;}
        if(b[i]<c[i] and b[low]<=b[0] and c[low]<=c[0]) {cout<<a<<c<<b;return 0;}
        if(b[i]<c[i] and b[low]<=b[0] and c[low]>=c[0]) {cout<<c<<a<<b;return 0;}

     }
     if(low==b.size() and mid==a.size()){
        if(a[i]>c[i] and a[low]>=a[0] and c[low]>=c[0]) {cout<<a<<c<<b;return 0;}
        if(a[i]>c[i] and a[low]>=a[0] and c[low]<=c[0]) {cout<<a<<b<<c;return 0;}
        if(a[i]>c[i] and a[low]<=a[0] and c[low]<=c[0]) {cout<<b<<a<<c;return 0;}
        if(a[i]<c[i] and a[low]>=a[0] and c[low]>=c[0]) {cout<<c<<a<<b;return 0;}
        if(a[i]<c[i] and a[low]<=a[0] and c[low]<=c[0]) {cout<<b<<c<<a;return 0;}
        if(a[i]<c[i] and a[low]<=a[0] and c[low]>=c[0]) {cout<<c<<b<<a;return 0;}

     }
     if(low==c.size() and mid==b.size()){
        if(b[i]>a[i] and b[low]>=b[0] and a[low]>=a[0]) {cout<<b<<a<<c;return 0;}
        if(b[i]>a[i] and b[low]>=b[0] and a[low]<=a[0]) {cout<<b<<c<<a;return 0;}
        if(b[i]>a[i] and b[low]<=b[0] and a[low]<=a[0]) {cout<<c<<b<<a;return 0;}
        if(b[i]<a[i] and b[low]>=b[0] and a[low]>=a[0]) {cout<<a<<b<<c;return 0;}
        if(b[i]<a[i] and b[low]<=b[0] and a[low]<=a[0]) {cout<<c<<a<<b;return 0;}
        if(b[i]<a[i] and b[low]<=b[0] and a[low]>=a[0]) {cout<<a<<c<<b;return 0;}

     }
    if(low==c.size() and mid==a.size()){
        if(a[i]>b[i] and a[low]>=a[0] and b[low]>=b[0]) {cout<<a<<b<<c;return 0;}
        if(a[i]>b[i] and a[low]>=a[0] and b[low]<=b[0]) {cout<<a<<c<<b;return 0;}
        if(a[i]>b[i] and a[low]<=a[0] and b[low]<=b[0]) {cout<<c<<a<<b;return 0;}
        if(a[i]<b[i] and a[low]>=a[0] and b[low]>=b[0]) {cout<<b<<a<<c;return 0;}
        if(a[i]<b[i] and a[low]<=a[0] and b[low]<=b[0]) {cout<<c<<b<<a;return 0;}
        if(a[i]<b[i] and a[low]<=a[0] and b[low]>=b[0]) {cout<<b<<c<<a;return 0;}

     }
     if(low==a.size() and mid==c.size()){
        if(c[i]>b[i] and c[low]>=c[0] and b[low]>=b[0]) {cout<<c<<b<<a;return 0;}
        if(c[i]>b[i] and c[low]>=c[0] and b[low]<=b[0]) {cout<<c<<a<<b;return 0;}
        if(c[i]>b[i] and c[low]<=c[0] and b[low]<=b[0]) {cout<<a<<c<<b;return 0;}
        if(c[i]<b[i] and c[low]>=c[0] and b[low]>=b[0]) {cout<<b<<c<<a;return 0;}
        if(c[i]<b[i] and c[low]<=c[0] and b[low]<=b[0]) {cout<<a<<b<<c;return 0;}
        if(c[i]<b[i] and c[low]<=c[0] and b[low]>=b[0]) {cout<<b<<a<<c;return 0;}

     }
     if(low==b.size() and mid==c.size()){
        if(c[i]>a[i] and c[low]>=c[0] and a[low]>=a[0]) {cout<<c<<a<<b;return 0;}
        if(c[i]>a[i] and c[low]>=c[0] and a[low]<=a[0]) {cout<<c<<b<<a;return 0;}
        if(c[i]>a[i] and c[low]<=c[0] and a[low]<=a[0]) {cout<<b<<c<<a;return 0;}
        if(c[i]<a[i] and c[low]>=c[0] and a[low]>=a[0]) {cout<<a<<c<<b;return 0;}
        if(c[i]<a[i] and c[low]<=c[0] and a[low]<=a[0]) {cout<<b<<a<<c;return 0;}
        if(c[i]<a[i] and c[low]<=c[0] and a[low]>=a[0]) {cout<<a<<b<<c;return 0;}

     }
   }  }
      if(a.size()==b.size() or b.size()==c.size() or a.size()==b.size()){
         for(int i=low;i<=maxx;i++){
            if(a.size()==b.size() and c.size()>a.size()){
                if(c[low]>=c[0]) {cout<<c<<a<<b;return 0;}
                if(c[low]<=c[0]) {cout<<a<<b<<c;return 0;}
            }
            if(a.size()==c.size() and b.size()>a.size()){
                if(b[low]>=b[0]) {cout<<b<<a<<c;return 0;}
                if(b[low]<=b[0]) {cout<<c<<a<<b;return 0;}
            }
            if(b.size()==c.size() and a.size()>b.size()){
                if(a[low]>=a[0]) {cout<<a<<b<<c;return 0;}
                if(a[low]<=a[0]) {cout<<c<<b<<a;return 0;}
            }
            if(a.size()==b.size() and c.size()<a.size()){
                if(a[low]<=a[0]) {cout<<c<<a<<b;return 0;}
                if(a[low]>=a[0]) {cout<<a<<b<<c;return 0;}
            }
            if(a.size()==c.size() and b.size()<a.size()){
                if(a[low]<=a[0]) {cout<<b<<a<<c;return 0;}
                if(a[low]>=a[0]) {cout<<a<<c<<b;return 0;}
            }
            if(c.size()==b.size() and a.size()<c.size()){
                if(c[low]<=c[0]) {cout<<a<<b<<c;return 0;}
                if(c[low]>=c[0]) {cout<<c<<b<<a;return 0;}
            }
         }
      }

   if(low==a.size() and mid==b.size()){
     if(b[low]>=b[0] and c[low]>=b[0] and c[mid]>=c[0] and c[mid]>=c[low]) { cout<<c<<b<<a;return 0; }
     if(b[low]>=b[0] and c[low]>=b[0] and c[mid]<=c[0]) { cout<<b<<c<<a;return 0; }
     if(b[low]<=b[0] and c[low]<=b[0] and c[mid]>=c[0]) { cout<<a<<c<<b;return 0; }
     if(b[low]<=b[0] and c[low]<=b[0] and c[mid]<=c[0]) { cout<<a<<b<<c;return 0; }
   }
   if(low==a.size() and mid==c.size()){
     if(c[low]>=c[0] and b[low]>=c[0] and b[mid]>=b[0]) { cout<<b<<c<<a;return 0; }
     if(c[low]>=c[0] and b[low]>=c[0] and b[mid]<=b[0]) { cout<<c<<b<<a;return 0; }
     if(c[low]<=c[0] and b[low]<=c[0] and b[mid]>=b[0]) { cout<<a<<b<<c;return 0; }
     if(c[low]<=c[0] and b[low]<=c[0] and b[mid]<=b[0]) { cout<<a<<c<<b;return 0; }
   }
   if(low==b.size() and mid==c.size()){
     if(c[low]>=c[0] and a[low]>=c[0] and a[mid]>=a[0]) { cout<<a<<c<<b;return 0; }
     if(c[low]>=c[0] and a[low]>=c[0] and a[mid]<=a[0]) { cout<<c<<a<<b;return 0; }
     if(c[low]<=c[0] and a[low]<=c[0] and a[mid]>=a[0]) { cout<<b<<a<<c;return 0; }
     if(c[low]<=c[0] and a[low]<=c[0] and a[mid]<=a[0]) { cout<<b<<c<<a;return 0; }
   }
   if(low==c.size() and mid==b.size()){
     if(b[low]>=b[0] and a[low]>=b[0] and a[mid]>=a[0]) { cout<<a<<b<<c;return 0; }
     if(b[low]>=b[0] and a[low]>=b[0] and a[mid]<=a[0]) { cout<<b<<a<<c;return 0; }
     if(b[low]<=b[0] and a[low]<=b[0] and a[mid]>=a[0]) { cout<<c<<a<<b;return 0; }
     if(b[low]<=b[0] and a[low]<=b[0] and a[mid]<=a[0]) { cout<<c<<b<<a;return 0; }
   }
   if(low==c.size() and mid==a.size()){
     if(a[low]>=a[0] and b[low]>=a[0] and b[mid]>=b[0]) { cout<<b<<a<<c;return 0; }
     if(a[low]>=a[0] and b[low]>=a[0] and b[mid]<=b[0]) { cout<<a<<b<<c;return 0; }
     if(a[low]<=a[0] and b[low]<=a[0] and b[mid]>=b[0]) { cout<<c<<b<<a;return 0; }
     if(a[low]<=a[0] and b[low]<=a[0] and b[mid]<=b[0]) { cout<<c<<a<<b;return 0; }
   }
   if(low==b.size() and mid==a.size()){
     if(a[low]>=a[0] and c[low]>=a[0] and c[mid]>=c[0]) { cout<<c<<a<<b;return 0; }
     if(a[low]>=a[0] and c[low]>=a[0] and c[mid]<=c[0]) { cout<<a<<c<<b;return 0; }
     if(a[low]<=a[0] and c[low]<=a[0] and c[mid]>=c[0]) { cout<<b<<c<<a;return 0; }
     if(a[low]<=a[0] and c[low]<=a[0] and c[mid]<=c[0]) { cout<<b<<a<<c;return 0; }
   }

return 0;
}