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

def count(s):
    d = {}
    for i in s:
        if i in d:
            d[i] += 1
        else:
            d[i] = 1
    return d

def write(k, l):
    global d, d1, d2, a, b
    res = ''
    for i in d1:
        if i in d:
            d[i] -= d1[i]*k
    res += a*k
    for i in d2:
        if i in d:
            d[i] -= d2[i]*l
    res += b*l
    for i in d:
        res += i*d[i]
    print(res)

def write1(k, e):
    global d1, d2, a, b
    #print(e)
    for i in d1:
        if i in e:
            e[i] -= d1[i]*k
    res2 = 1000000000
    for i in d2:
        if i in e:
            res2 = min(res2, e[i] // d2[i])
        else:
            res2 = 0
    return res2

def write2(l, e):
    global d1, d2, a, b
    #print(e)
    for i in d2:
        if i in e:
            e[i] -= d2[i]*l
    res1 = 10000000000
    for i in d1:
        if i in e:
            res1 = min(res1, e[i] // d1[i])
        else:
            res1 = 0
    return res1

d, d1, d2 = count(s), count(a), count(b)

res1, res2 = 100000000000, 10000000000
for i in d1:
    if i in d:
        res1 = min(res1, d[i] // d1[i])
    else:
        res1 = 0
for i in d2:
    if i in d:
        res2 = min(res2, d[i] // d2[i])
    else:
        res2 = 0
if (res1 == 0) or (res2 == 0):
    write(res1, res2)
    exit()

e = {}
for i in d:
    e[i] = d[i]
t1 = write1(res1, d)
t2 = write2(res2, e)
if t1 + res1 > t2 + res2:
    write(res1, t1)
else:
    write(res2, t2)