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.
a = input()
b = input()
c = input()

if len(c) < len(b):b,c = c,b

counta = {}
for i in a:
    if i in counta:counta[i]+=1
    else:counta[i]=1

countb = {}
for i in b:
    if i in countb : countb[i]+=1
    else : countb[i]=1

countc = {}
for i in c:
    if i in countc : countc[i]+=1
    else : countc[i]=1

maxV = 0
count_of_b = 0
count_of_c = 0
opop=0
while(True):
    temp1 = 10000000
    for i in countc:
        if i in counta:temp1 = min(temp1,counta[i]//countc[i])
        else:
            temp1=0
            break

    if opop +temp1>maxV:
        count_of_b = opop
        count_of_c = temp1

    dummy = {}
    for p,q in counta.items():
        dummy[p] = q

    tester = False
    for i in countb:
        if i in counta and counta[i]>=countb[i]: dummy[i] -= countb[i]
        else:
            tester=True
            break

    if tester:break
    else:
        for p,q in dummy.items():
            counta[p] = q
    opop+=1

ans = b*count_of_b + c*count_of_c
for i in counta:
    ans+=i*counta[i]

print(ans)

