Professor GukiZ doesn't accept string as they are. He likes to swap some letters in string to obtain a new one.

GukiZ has strings *a*, *b*, and *c*. He wants to obtain string *k* by swapping some letters in *a*, so that *k* should contain as many non-overlapping substrings equal either to *b* or *c* as possible. Substring of string *x* is a string formed by consecutive segment of characters from *x*. Two substrings of string *x* overlap if there is position *i* in string *x* occupied by both of them.

GukiZ was disappointed because none of his students managed to solve the problem. Can you help them and find one of possible strings *k*?
The first line contains string *a*, the second line contains string *b*, and the third line contains string *c* (1 ≤ |*a*|, |*b*|, |*c*| ≤ 10<sup class="upper-index">5</sup>, where |*s*| denotes the length of string *s*).

All three strings consist only of lowercase English letters. 

It is possible that *b* and *c* coincide.
from sys import stdin, stdout
import copy
"""
    n = stdin.readline()
    arr = [int(x) for x in stdin.readline().split()]
    stdout.write(str(summation))
"""
a = input()
b = input()
c = input()
dicta = {}
dictb = {}
dictc = {}

for i in a :
    if i not in dicta :
        dicta[i] = 1
    else :
        dicta[i] = dicta[i]+1
dicta2 = copy.deepcopy(dicta)

for i in b :
    if i not in dictb :
        dictb[i] = 1
    else :
        dictb[i] = dictb[i]+1

for i in c :
    if i not in dictc :
        dictc[i] = 1
    else :
        dictc[i] = dictc[i]+1

"""###"""
minib = 1000001
for i in dictb :
    if i in dicta and dicta[i]//dictb[i] > 0:
        if dicta[i]//dictb[i] <= minib :
            minib = dicta[i]//dictb[i]
    else :
        minib = 0
        break
for i in dicta :
    if i in dictb :
        dicta[i] = dicta[i] - minib*dictb[i]
minic1 = 1000001
for i in dictc :
    if i in dicta and dicta[i]//dictc[i]>0:
        if dicta[i]//dictc[i] <= minic1 :
            minic1 = dicta[i]//dictc[i]
    else :
        minic1 = 0
        break
ans1 = minib*b + minic1*c

"""###"""
minic = 1000001
for i in dictc :
    if i in dicta2 and dicta2[i]//dictc[i]>0:
        if dicta2[i]//dictc[i] <= minic :
            minic = dicta2[i]//dictc[i]
    else :
        minic = 0
        break
for i in dicta2 :
    if i in dictc :
        dicta2[i] = dicta2[i] - minic*dictc[i]
minib2 = 1000001
for i in dictb :
    if i in dicta2 and dicta2[i]//dictb[i]>0:
        if dicta2[i]//dictb[i] <= minib2 :
            minib2 = dicta2[i]//dictb[i]
    else :
        minib2 = 0
        break
ans2 = minib2*b + minic*c

"""###"""
if minib+minic1>=minib2+minic :

    for i in dicta :
        if i in dictc :
            dicta[i] = dicta[i] - minic1*dictc[i]
            ans1 = ans1+i*dicta[i]
        else :
            ans1 = ans1+i*dicta[i]
    
    stdout.write(ans1)

else :

    for i in dicta2 :
        if i in dictb :
            dicta2[i] = dicta2[i] - minib2*dictb[i]
            ans2 = ans2+i*dicta2[i]
        else :
            ans2 = ans2+i*dicta2[i]
    
    stdout.write(ans2)