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 main() {
  string a, b, c;
  cin >> a >> b >> c;
  int arr[26];
  int brr[26];
  int len = a.length();
  char store1[100001];
  char store2[100001];
  for (int i = 0; i < len; i++) {
    arr[(int)a[i] - 97]++;
    brr[(int)a[i] - 97]++;
  }
  int lenb = b.length();
  int lenc = c.length();
  int count1 = 0;
  int i = 0;
  int d = 0;
  while (3) {
    if (arr[(int)b[i] - 97] == 0) {
      d = d - i;
      while (i >= 0) {
        i--;
        arr[(int)b[i] - 97]++;
      }
      break;
    } else {
      store1[d++] = b[i];
      arr[(int)b[i] - 97]--;
      if (i == lenb - 1) count1++;
      i++;
      i = i % lenb;
    }
  }
  i = 0;
  while (3) {
    if (arr[(int)c[i] - 97] == 0)
      break;
    else {
      store1[d++] = c[i];
      arr[(int)c[i] - 97]--;
      if (i == lenc - 1) count1++;
      i++;
      i = i % lenc;
    }
  }
  for (int j = 0; j < 26; j++) {
    while (arr[j] != 0) {
      store1[d++] = (char)(j + 97);
      arr[j]--;
    }
  }
  int count2 = 0;
  i = 0;
  d = 0;
  while (3) {
    if (brr[(int)c[i] - 97] == 0) {
      d = d - i;
      while (i >= 0) {
        i--;
        brr[(int)c[i] - 97]++;
      }
      break;
    } else {
      store2[d++] = c[i];
      brr[(int)c[i] - 97]--;
      if (i == lenc - 1) count2++;
      i++;
      i = i % lenc;
    }
  }
  i = 0;
  while (3) {
    if (brr[(int)b[i] - 97] == 0)
      break;
    else {
      store2[d++] = b[i];
      brr[(int)b[i] - 97]--;
      if (i == lenb - 1) count2++;
      i++;
      i = i % lenb;
    }
  }
  for (int j = 0; j < 26; j++) {
    while (brr[j] != 0) {
      store2[d++] = (char)(j + 97);
      brr[j]--;
    }
  }
  if (count1 > count2) {
    int k = 0;
    while (store1[k] != '\0') {
      cout << store1[k];
      k++;
    }
    cout << endl;
  } else {
    int u = 0;
    while (store2[u] != '\0') {
      cout << store2[u];
      u++;
    }
    cout << endl;
  }
  return 0;
}
