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

#include <bits/stdc++.h>
using namespace std;
int DAT1[255];
int DAT2[255];
int DAT3[255];
int main() {
  string ss1, ss2, ss3;
  cin >> ss1;
  for (int i = 0; i < (int)ss1.size(); i++) DAT1[ss1[i]]++;
  cin >> ss2;
  for (int i = 0; i < (int)ss2.size(); i++) DAT2[ss2[i]]++;
  cin >> ss3;
  for (int i = 0; i < (int)ss3.size(); i++) DAT3[ss3[i]]++;
  long long a = 0x7FFFFFFF, b = 0x7FFFFFFF;
  long long mini = 0x7FFFFFFF;
  for (int i = 0; i < ss2.size(); i++) {
    a = min(a, (long long)DAT1[ss2[i]] / DAT2[ss2[i]]);
  }
  cout << a << endl;
  mini = 0x7FFFFFFF;
  for (int i = 0; i < ss3.size(); i++) {
    b = min(b, (long long)DAT1[ss3[i]] / DAT3[ss3[i]]);
  }
  cout << b << endl;
  int sec1 = 10000000, sec2 = 10000000;
  if (a == 0 & b == 0) return cout << ss1 << endl, 0;
  for (int i = 0; i < ss2.size(); i++) {
    DAT1[ss2[i]] -= a;
  }
  for (int i = 0; i < ss3.size(); i++) {
    sec1 = min(sec1, DAT1[ss3[i]] / DAT3[ss3[i]]);
  }
  for (int i = 0; i < ss2.size(); i++) {
    DAT1[ss2[i]] += a;
  }
  for (int i = 0; i < ss3.size(); i++) {
    DAT1[ss3[i]] -= b;
  }
  for (int i = 0; i < ss2.size(); i++) {
    sec2 = min(sec2, DAT1[ss2[i]] / DAT2[ss2[i]]);
  }
  for (int i = 0; i < ss3.size(); i++) {
    DAT1[ss3[i]] += b;
  }
  cout << sec1 << " " << sec2 << endl;
  if (a + sec1 >= b + sec2) {
    for (int i = 0; i < ss2.size(); i++) {
      DAT1[ss2[i]] -= a;
    }
    for (int i = 0; i < ss3.size(); i++) DAT1[ss3[i]] -= sec1;
    for (int i = 0; i < (int)a; i++) cout << ss2;
    for (int i = 0; i < (int)sec1; i++) cout << ss3;
    for (int i = 0; i < ss1.size(); i++) {
      while (DAT1[ss1[i]]) cout << ss1[i], DAT1[ss1[i]]--;
    }
  } else {
    for (int i = 0; i < ss3.size(); i++) {
      DAT1[ss3[i]] -= b;
    }
    for (int i = 0; i < ss2.size(); i++) DAT1[ss2[i]] -= sec2;
    for (int i = 0; i < (int)b; i++) cout << ss3;
    for (int i = 0; i < (int)sec2; i++) cout << ss2;
    for (int i = 0; i < ss1.size(); i++) {
      if (DAT1[ss1[i]]) {
        while (DAT1[ss1[i]]) cout << ss1[i], DAT1[ss1[i]]--;
      }
    }
  }
  return 0;
}
