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

com = set(b).intersection(set(c))

aSet_dict = {}
# comA_dict = {}
comB_dict = {}
comC_dict = {}

leftB_dict = {}
leftC_dict = {}

def search(string, string_set, dictionary) :
    for ch in string_set:
        index = -1
        while True:
            index = string.find(ch, index + 1)
            if index >= 0:
                if ch in dictionary.keys():
                    dictionary[ch] = dictionary[ch] + 1
                else:
                    dictionary[ch] = 1
          else:
                break

# search(a, com, comA_dict)
search(b, com, comB_dict)
search(c, com, comC_dict)

search(a, set(a), aSet_dict)

search(b, set(filter(lambda s: not s in com, set(b))), leftB_dict)
search(c, set(filter(lambda s: not s in com, set(c))), leftC_dict)

bMin = 100000
for ch in comB_dict.keys():
    if aSet_dict[ch] // comB_dict[ch] < bMin:
        bMin = aSet_dict[ch] // comB_dict[ch]
cMin = 100000
for ch in comC_dict.keys():
    if aSet_dict[ch] // comC_dict[ch] < cMin:
        cMin = aSet_dict[ch] // comC_dict[ch]

b_dict = comB_dict
c_dict = comC_dict
b_dict.update(leftB_dict)
c_dict.update(leftC_dict)

# print(aSet_dict)
# print(b_dict)
# print(c_dict)
# most = 0
if bMin >= cMin:
    bbMin = 100000
    for ch in b_dict.keys():
        if ch in aSet_dict.keys():
            if aSet_dict[ch] // b_dict[ch] < bbMin:
                bbMin = aSet_dict[ch] // b_dict[ch]
        else:
            bbMin = 0
            break
    if bbMin > 0:
        for ch in b_dict.keys():
            aSet_dict[ch] -= b_dict[ch] * bbMin
    # print(aSet_dict)
    # most += bbMin
    
    ccMin = 100000
    # print (c_dict.keys())
    for ch in c_dict.keys():
        if ch in aSet_dict.keys():
            if aSet_dict[ch] // c_dict[ch] < ccMin:
                ccMin = aSet_dict[ch] // c_dict[ch]
        else:
            ccMin = 0
            break
    if ccMin > 0:
        for ch in c_dict.keys():
            aSet_dict[ch] -= c_dict[ch] * ccMin
    # most += ccMin
    # print(most)
    print(b * bbMin, end = "")
    print(c * ccMin, end = "")
    for ch in aSet_dict.keys():
        if aSet_dict[ch] > 0:
            print(ch * aSet_dict[ch], end = "")
    print()
else:
    ccMin = 100000
    for ch in c_dict.keys():
        if ch in aSet_dict.keys():
            if aSet_dict[ch] // c_dict[ch] < ccMin:
                ccMin = aSet_dict[ch] // c_dict[ch]
        else:
            ccMin = 0
            break
    if ccMin > 0:
        for ch in c_dict.keys():
            aSet_dict[ch] -= c_dict[ch] * ccMin
    most += ccMin

    bbMin = 100000
    for ch in b_dict.keys():
        if ch in aSet_dict.keys():
            if aSet_dict[ch] // b_dict[ch] < bbMin:
                bbMin = aSet_dict[ch] // b_dict[ch]
        else:
            bbMin = 0
            break
    if bbMin > 0:
        for ch in b_dict.keys():
            aSet_dict[ch] -= b_dict[ch] * bbMin
    
    # most += bbMin
    
    # print(most)   
    print(b * bbMin, end = "")
    print(c * ccMin, end = "")
    for ch in aSet_dict.keys():
        if aSet_dict[ch] > 0:
            print(ch * aSet_dict[ch], end = "")
    print()

   
    
