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


def can(c, s):
    cc = Counter(s)
    return (c & cc) == cc


def how(c, c1):
    m = None
    for k in c1.keys():
        q = 0
        if k in c:
            q = c[k] // c1[k]
        if q == 0:
            return 0
        if m is None or m > q:
            m = q

    return m


def diff(c, f, c1):
    r = c.copy()
    for k in c1:
        r[k] -= f * c1[k]
    return r


def count(k, s1, s2):
    c = Counter(k)
    c1 = Counter(s1)
    c2 = Counter(s2)

    m = 0
    a = 0
    b = 0
    for i in range(how(c, c1)):
        d = diff(c, i + 1, c1)
        q = how(d, c2)
        if i + q + 1 > m:
            a = i + 1
            b = q
            m = a + b

    return a, b


def build(k, s1, s2, a, b):
    c = Counter(k)
    c1 = Counter(s1)
    c2 = Counter(s2)

    s = s1 * a + s2 * b
    d = diff(c, a, c1)
    d = diff(d, b, c2)
    for k in d.keys():
        s += k * d[k]

    return s


if __name__ == '__main__':
    k = input()
    s1 = input()
    s2 = input()

    a1, b1 = count(k, s1, s2)
    a2, b2 = count(k, s2, s1)
    if a1 + b1 > a2 + b2:
        print(build(k, s1, s2, a1, b1))
    else:
        print(build(k, s2, s1, a2, b2))