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.
def process(a, b, c):
    d = {}
    for c1 in a:
        if c1 not in d:
            d[c1] = [0, 0, 0]
        d[c1][0]+=1
    b_possible = True
    c_possible = True
    for c1 in b:
        if c1 not in d:
            b_possible = False
        else:
            d[c1][1]+=1
            if d[c1][1] > d[c1][0]:
                b_possible = False
    for c1 in c:
        if c1 not in d:
            c_possible = False
        else:
            d[c1][2]+=1
            if d[c1][2] > d[c1][0]:
                c_possible = False
    if not b_possible and not c_possible:
        return a
    elif not b_possible and c_possible:
        my_max = float('inf')
        for c1 in d:
            if d[c1][2] > 0:
                my_max = min(my_max, d[c1][0]//d[c1][2])
        answer = c*my_max
        for c1 in d:
            value = d[c1][0]-my_max*d[c1][2]
            answer = answer+c1*value
        return answer
    elif b_possible and not c_possible:
        my_max = float('inf')
        for c1 in d:
            if d[c1][1] > 0:
                my_max = min(my_max, d[c1][0]//d[c1][1])
        answer = b*my_max
        for c1 in d:
            value = d[c1][0]-my_max*d[c1][1]
            answer = answer+c1*value
        return answer
    else:
        b_max = float('inf')
        for c1 in d:
            if d[c1][1] > 0:
                b_max = min(b_max, d[c1][0]//d[c1][1])
        total = [b_max, b_max, 0]  
        for i in range(b_max+1):
            c_max = float('inf')
            for c1 in d:
                if d[c1][2] > 0:
                    c_max= min(c_max, (d[c1][0]-i*d[c1][1])//d[c1][2])
            total = max([i+c_max, i, c_max], total)
        t, b_count, c_count = total
        answer = b_count*b+c_count*c
        for c1 in d:
            value = d[c1][0]-b_count*d[c1][1]-c_count*d[c1][2]
            answer = answer+c1*value
        return answer
    
a = input()
b = input()
c = input()
print(process(a, b, c))