brtakoktrosttttttttttosafasfkalsfkodfdasiofhadfhasdsajfdsafoasodsafahaihfdisoadspapsapiosapdsajdipsahdhasuirhaeuifhhfkjgosooooooooodafdfioottttafdsafaddfuiasdjfjasdo
okat
tako
 aleksandrehteosidatedodam
evo
si
 goodbyeihopecontestisntsohar
oh
god
 duxidimkeetoivas
dd
odi
 hellodeninobrdo
od
hel
 ikbalturkeybelieveinyou
bal
kan
 zdule
didins
meinkraft
 cumurcumur
um
cur
 ikatanictisinajboljiuhrvatskojakoprictasovojaviseakotijedosadno
javise
sine
 zlobobermyfriendandthanksforhelp
de
for
 navijamzaradnickiastabidrugo
druzina
djavola
 saljivdzijasamjaneki
neki
ja
 bumbumdzejsikerol
bumbum
bum
 svetislavgajicpoznatijikaosvetaxxx
slavi
slavu
 princeofpersiayouhavegreatcontestbutinwrongtime
op
pera
 pozdravizamarkamatovicaaleksandracveticainenadaslagalicustanisica
vas
rad
 dreamoonhasonedream
no
no
 jankosustersicneceovoraditi
cosovic
oce
 milenicnikolaitisideotakmicenja
elem
nik
 touristyouaregreatguy
tourist
guy
 lukavpastaakojelukav
a
u
 xxxbbbcccoca
ca
cb
 aaaaaabababaaa
aa
a
 petryouaregoodandyouhavegoodblogs
blog
rega
 lebronnojameslebronprogrammers
je
bro
 mztskopjetisisampiosrcenaterenostaviajdezanaspobedi
mzt
optee
 gukimikazedauradimseminarskidodatnohumorhumor
dp
mrzime
 razredninjegosgrebovicdobarcoveklosbasketas
ne
go
 pozdravzamojeodeljenjeiprofesoreocudabudempetnula
bojan
cao
 damandicnenapravicheckerzeznulibise
man
ker
 pozdravizazenskudecunecuvasodvajatidaseneprotumacipogresno
cao
deco
 egoryouaregoodbutcantsolveeverythinginonehour
eat
your
 lemigazalemiolemilicomzalemljenje
lemi
zlo
 randomusername
umno
umno
 thisiscornercase
youhavetwolongerstrings
ibelivethatyoudontmissit
 oduleodule
xgrizx
ivanstosicprvi
 molimprofesorkuengleskogdamidapetjasamdobarcovekitrudimseiztogaiakosamoperisan
hvala
unapred
 djeneralmilomirstefanovic
radi
nesto
 balsabratepozdravimajudevojku
oj
zdrav
 iwanttothanktomygrandmaheisveryimportantpersoninmylife
thanks
stanka

takotakotakotakotakoaaaaaaaaaaaaaaaaaaaaaabddddddddddddddddddeffffffffffffffffffghhhhhhhhhiiiiiiiiijjjjjloooooooooooooooooppppprrrssssssssssssssssssssstttttttttttuuu
 siaaaaddddeeeehklmnoorstt
 ohohgodabceeeiinnooprsssttty
 odiadeeiikmstuvx
 ododhelbeilnnor
 kanbbeeeeiiikllortuuvyy
 deluz
 umumcurcur
 sinesineaaaaaaaaabccddhiiiiiijjjjjkkkklnooooooooprrssstttttuvvv
 dedeforforaabbehhikllmnnnoprstyz
 druzinaaaaaabcdgiiijkmnorstv
 nekijajajaadiilmssvz
 bumbumdeeijklorsz
 slaviaaaaceegiiijjknoopsstttvvxxxz
 peraperaabcceeeefgghiiiimnnnnoooorrsstttttuuvwy
 vasvasvasradradradaaaaaaaaaaccccceeegiiiiiiikklllmmnnnnoopstttuzz
 nonoaaaddeeehmmorrs
 oceoceaadeiiijknnorrsssttuv
 elemniknikaaaccdeiiiiijlmnoostt
 touristguyguyaaeeorrt
 aaaaauuejkkkllopstvv
 cacbcbcboxxx
 aaaaaaaaaaabbb
 blogregaregaadddehnoooooopstuuvyy
 jebrobroaaeeegllmmmnnnooprrrss
 mztopteeopteeopteeaaaaaabcddiiiiijjkmnnnorrssssssvz
 mrzimeaaaaaddddeghhiiiikkkmmmnnoooorrrsstuuuu
 nenegogoaaaabbbccddeeeiijkklooorrrrsssstvvz
 bojancaoaaddddeeeeeeeefijjllmmnooooppprrrstuuuvzz
 mankeraaabcccddeeeehiiiilnnnprsuvzz
 decodecodecoaaaaaaadeeegiiijkmnnnnooppprrrssssttuuuuvvvzzz
 eateatyouryourbcdeeeeggghhiilnnnnooooorrstuvv
 lemilemilemilemizlozloaaaceegjjmn
 umnoaadeemnrrs
 acceehiinorrssst
 ddeelloouu
 unapredunapredaaaaaaabcddeeeeefgggiiiiiiijkkkkllmmmmmmoooooooooprrrsssssstttvz
 radinestoaceefiijllmmnorv
 ojojzdravaaaabbdeeiklmprstuuv
 stankaaaadeeeefghhiiiiilmmmmnnnnnoooopprrrrstttttvwyyy

import java.util.Scanner;


public class CF307B {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int[] charsa = new int[256];
		String a = sc.next();
		String b = sc.next();
		String c = sc.next();
		
		char[] cha = a.toCharArray();
		char[] chb = b.toCharArray();
		char[] chc = c.toCharArray();
		int[] charsb = new int[256];
		int[] charsc = new int[256];
		for(int i=0; i<a.length(); ++i){
			++charsa[(int)cha[i]];
		}
		for(int i=0; i<b.length(); ++i){
			++charsb[(int)chb[i]];
		}
		for(int i=0; i<c.length(); ++i){
			++charsc[(int)chc[i]];
		}
		
		int a_char = (int)'a';
		int z_char = (int)'z';
		
		int count = Integer.MAX_VALUE;
		
		for(int i=a_char; i<=z_char; ++i){
			if(charsb[i] != 0){
				if(charsa[i]/charsb[i] < count)
					count = charsa[i]/charsb[i];
			}
		}
		
		int count2 = Integer.MAX_VALUE;
		
		for(int i=a_char; i<=z_char; ++i){
			if(charsc[i] != 0){
				if(charsa[i]/charsc[i] < count2)
					count2 = charsa[i]/charsc[i];
			}
		}
		
		int tmp = Integer.MAX_VALUE;
		
		for(int i=a_char; i<=z_char; ++i){
			if(charsc[i] != 0){
				if((charsa[i] - count* charsb[i])/charsc[i] < tmp)
					tmp = (charsa[i] - count* charsb[i])/charsc[i];
			}
		}
		
		int tmp2 = Integer.MAX_VALUE;
		
		for(int i=a_char; i<=z_char; ++i){
			if(charsb[i] != 0){
				if((charsa[i] - count2*charsc[i])/charsb[i] < tmp2)
					tmp2 = (charsa[i] - count2*charsc[i])/charsb[i];
			}
			
		}
		System.out.println(count + " " +  tmp + " " + count2 + " "+ tmp2);
		if(count + tmp >= count2 + tmp2){
			for(int i=0; i<count; ++i)
				System.out.print(b);
			for(int i=0; i<tmp; ++i)
				System.out.print(c);
			for(int i=a_char; i<=z_char; ++i){
				char chari = (char)i;

				//System.out.println(chari + " " + (charsa[j]-count*charsb[j]-tmp*charsc[j]));
				for(int j=0; j<charsa[i]-count*charsb[i]-tmp*charsc[i];++j)
					System.out.print(chari);
				
			}
		}
		else{
			for(int i=0; i<count2; ++i)
				System.out.print(c);
			for(int i=0; i<tmp2; ++i)
				System.out.print(b);
			for(int i=a_char; i<=z_char; ++i){
				char chari = (char)i;
				for(int j=0; j<charsa[i]-tmp2*charsb[i]-count2*charsc[i];++j)
					System.out.print(chari);
				
			}
		}
		
		
		
		
	}

}
