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.
import collections

a = input()
b = input()
c = input()

d = collections.defaultdict(int)
d1 = collections.defaultdict(int)

e = collections.defaultdict(int)
f = collections.defaultdict(int)

for i in a:
    d[i] = d[i]+1
    d1[i] = d1[i]+1

for i in b:
    e[i] = e[i]+1

for i in c:
    f[i] = f[i]+1

#print(d,d1,e,f)



count = 1000000
s= ""

for i in e:
    #print(i,e[i])
    x = d[i]//e[i]
    if(count>x):
        count = x

for i in e:
    #print(i,e[i])
    d[i] = d[i] - (count*e[i])

#print(d,d1,e,f)

s = s + (b*count)
c1 = count
count = 1000000



for i in f:
    #print(i,f[i])
    x = d[i]//f[i]
    if(count>x):
        count = x

for i in f:
    #print(i,f[i])
    d[i] = d[i] - (count*f[i])

s = s + (c*count)
c1 = c1 + count


for i in d:
    s = s+(i*d[i])
#print(d,d1,e,f)

#print(s)





count = 1000000
s1= ""

for i in f:
    x = d1[i]//f[i]
    if(count>x):
        count = x

for i in f:
    d1[i] = d1[i] - (count*f[i])

s1 = s1 + (c*count)
c2 = count
count = 1000000

#print(d1,e)

for i in e:
    x = d1[i]//e[i]
    if(count>x):
        count = x

for i in e:
    d1[i] = d1[i] - (count*e[i])

s1 = s1 + (b*count)
c2 = c2 + count



for i in d1:
    s1 = s1+(i*d1[i])



if(c1>c2):
    print(s)
else:
    print(s1)








