#include <iostream>
#include <string>

using namespace std;

int pronadji_najveci_br(int br1, int br2, int br3){
	if(br1>=br2 && br1>=br3)
		return br1;
	if(br2>=br1 && br2>=br3)
		return br2;
	if(br3>=br1 && br3>=br2)
		return br3;
	
}

int main() {
	string a, b, c, r="", r2="";
	
	cin>>a>>b>>c;
	
	int max_len = pronadji_najveci_br(a.length(), b.length(), c.length());
	
	for(int i=0; i<max_len; i++){
		if(int(a.at(i%a.length())) > int(b.at(i%b.length())) && int(a.at(i%a.length())) > int(c.at(i%c.length()))){
			r += a;
			
			int max_len2 = 0;
			if(b.length() >= c.length()){
				max_len2 = b.length();
			}else{
				max_len2 = c.length();
			}
			
			for(int j=0; j<max_len2; j++){
				if(int(b.at(j%b.length())) > int(c.at(j%c.length()))){
					r2 += b;
					r2 += c;
					break;
				}
				if(int(c.at(j%c.length())) > int(b.at(j%b.length()))){
					r2 += c;
					r2 += b;
					break;
				}
			}
			if(r2 == ""){
				r2 += b;
				r2 += c;
			}
						
			break;
		}
		if(int(b.at(i%b.length())) > int(a.at(i%a.length())) && int(b.at(i%b.length())) > int(c.at(i%c.length()))){
			r += b;
			
			int max_len2 = 0;
			if(a.length() >= c.length()){
				max_len2 = a.length();
			}else{
				max_len2 = c.length();
			}
			
			for(int j=0; j<max_len2; j++){
				if(int(a.at(j%a.length())) > int(c.at(j%c.length()))){
					r2 += a;
					r2 += c;
					break;
				}
				if(int(c.at(j%c.length())) > int(a.at(j%a.length()))){
					r2 += c;
					r2 += a;
					break;
				}
			}
			if(r2 == ""){
				r2 += a;
				r2 += c;
			}
			
			break;
		}
		if(int(c.at(i%c.length())) > int(a.at(i%a.length())) && int(c.at(i%c.length())) > int(b.at(i%b.length()))){
			r += c;
			
			int max_len2 = 0;
			if(a.length() >= b.length()){
				max_len2 = a.length();
			}else{
				max_len2 = b.length();
			}
			
			for(int j=0; j<max_len2; j++){
				if(int(a.at(j%a.length())) > int(b.at(j%b.length()))){
					r2 += a;
					r2 += b;
					break;
				}
				if(int(b.at(j%b.length())) > int(a.at(j%a.length()))){
					r2 += b;
					r2 += a;
					break;
				}
			}
			if(r2 == ""){
				r2 += a;
				r2 += b;
			}
			
			break;
		}
	}
	if(r == ""){
		if(a.length()<=b.length() && a.length()<=c.length()){
			r+=a;	
			
			int max_len2 = 0;
			if(b.length() >= c.length()){
				max_len2 = b.length();
			}else{
				max_len2 = c.length();
			}
			
			for(int j=0; j<max_len2; j++){
				if(int(b.at(j%b.length())) > int(c.at(j%c.length()))){
					r2 += b;
					r2 += c;
					break;
				}
				if(int(c.at(j%c.length())) > int(b.at(j%b.length()))){
					r2 += c;
					r2 += b;
					break;
				}
			}
			if(r2 == ""){
				r2 += b;
				r2 += c;
			}
		}
		else{
			if(b.length()<=a.length() && b.length()<=c.length()){
				r+=b;	
				
				int max_len2 = 0;
				if(a.length() >= c.length()){
					max_len2 = a.length();
				}else{
					max_len2 = c.length();
				}
				
				for(int j=0; j<max_len2; j++){
					if(int(a.at(j%a.length())) > int(c.at(j%c.length()))){
						r2 += a;
						r2 += c;
						break;
					}
					if(int(c.at(j%c.length())) > int(a.at(j%a.length()))){
						r2 += c;
						r2 += a;
						break;
					}
				}
				if(r2 == ""){
					r2 += a;
					r2 += c;
				}
			}else{
				if(c.length()<=a.length() && c.length()<=b.length()){
					r+=c;	
					
					int max_len2 = 0;
					if(a.length() >= b.length()){
						max_len2 = a.length();
					}else{
						max_len2 = b.length();
					}
					
					for(int j=0; j<max_len2; j++){
						if(int(a.at(j%a.length())) > int(b.at(j%b.length()))){
							r2 += a;
							r2 += b;
							break;
						}
						if(int(b.at(j%b.length())) > int(a.at(j%a.length()))){
							r2 += b;
							r2 += a;
							break;
						}
					}
					if(r2 == ""){
						r2 += a;
						r2 += b;
					}
				}
			}
		}
	}
	
	cout<<r+r2;
	
	return 0;
}