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.
contest = True
if not contest:
    fin = open("in", "r")
inp = input if contest else lambda: fin.readline()[:-1]
read = lambda: tuple(map(int, inp().split()))

cstr = lambda s: dict([[v, s.count(v)] for v in set(s)])

a, b, c = inp(), inp(), inp()
ka, kb, kc = cstr(a), cstr(b), cstr(c)

def suka(s, ka, kb):
    ans = ""
    d = 10**10
    for k in kb:
        if not k in ka:
            return 0, ""
            d = 0
            break
        d = min(ka[k] // kb[k], d)
    for k in kb:
        if k in ka:
            ka[k] -= d * kb[k]
    #print(d, ka, b * d)
    return d, s * d

ka1 = cstr(a)
vb1 = suka(b, ka1, kb)
vc1 = suka(c, ka1, kc)
ans1 = vb1[1] + vc1[1]
for k in ka1: ans1 += ka1[k] * k

ka2 = cstr(a)
vc2 = suka(c, ka2, kc)
vb2 = suka(b, ka2, kb)
ans2 = vb2[1] + vc2[1]
for k in ka2: ans2 += ka2[k] * k

if vb1[0] + vc1[0] > vb2[0] + vc2[0]:
    print(ans1)
else:
    print(ans2)


