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.
sums = lambda n: int(n * (n + 1) / 2)  # sum from 1 to n
def im(): return map(int, input().split())
def il(): return list(map(int, input().split()))
def ii(): return int(input())

str1 = input()
str2 = input()
str3 = input()

freq1 = [0] * 26
freq2 = [0] * 26
freq3 = [0] * 26

for i in range(len(str1)):
    freq1[ord(str1[i])-97]+=1
for i in range(len(str2)):
    freq2[ord(str2[i])-97]+=1
for i in range(len(str3)):
    freq3[ord(str3[i])-97]+=1

freq1cpy = freq1.copy()
freq4 = [0] * 26
freq5 = [0] * 26

if len(str2) <= len(str3):
    isIt1=True
    for i in range(26):
        if freq1[i] < freq2[i]:
            isIt1=False
            freq1=freq1cpy.copy()
            break
        elif freq1[i] >= freq2[i] and freq2[i]>0:
            freq4[i]= freq1[i]//freq2[i]
            freq1[i]%=freq2[i]

    isIt2=True
    for i in range(26):
        if freq1[i] < freq3[i]:
            isIt2=False
            break
        elif freq1[i] >= freq3[i] and freq3[i]>0:
            freq5[i]+= freq1[i]//freq3[i]
            freq1[i]%=freq3[i]

    res=""
    if isIt1:
        # find the minimum non zero value in freq4
        minVal= freq4[ord(str2[0])-97]
        for i in range(26):
            if freq4[i]>0 and freq4[i]<minVal:
                minVal=freq4[i]
                break
        res+= str2 * minVal

        for i in range(26):
            freq1[i]+= (freq4[i]-minVal)*freq2[i] 


    if isIt2:
        # find the minimum non zero value in freq5
        minVal= freq5[ord(str3[0])-97]
        for i in range(26):
            if freq5[i]>0 and freq5[i]<minVal:
                minVal=i
                break
        res+= str3 * minVal

        for i in range(26):
            freq1[i]+= (freq5[i]-minVal)*freq3[i]


    for i in range(26):
        if freq1[i]>0:
            res+= chr(i+97)*freq1[i]
    print(res)
    
else:
    isIt1=True
    for i in range(26):
        if freq1[i] < freq3[i]:
            isIt1=False
            freq1=freq1cpy.copy()
            break
        elif freq1[i] >= freq3[i] and freq3[i]>0:
            freq4[i]= freq1[i]//freq3[i]
            freq1[i]%=freq3[i]

    isIt2=True
    for i in range(26):
        if freq1[i] < freq2[i]:
            isIt2=False
            break
        elif freq1[i] >= freq2[i] and freq2[i]>0:
            freq5[i]+= freq1[i]//freq2[i]
            freq1[i]%=freq2[i]

    res=""
    if isIt1:
        # find the minimum non zero value in freq4
        minVal= freq4[ord(str3[0])-97]
        for i in range(26):
            if freq4[i]>0 and freq4[i]<minVal:
                minVal=i
                break
        res+= str3 * minVal

        for i in range(26):
            freq1[i]+= (freq4[i]-minVal)*freq3[i] 


    if isIt2:
        # find the minimum non zero value in freq5
        minVal= freq5[ord(str2[0])-97]
        for i in range(26):
            if freq5[i]>0 and freq5[i]<minVal:
                minVal=freq5[i]
                break
        res+= str2 * minVal

        for i in range(26):
            freq1[i]+= (freq5[i]-minVal)*freq2[i]


    for i in range(26):
        if freq1[i]>0:
            res+= chr(i+97)*freq1[i]
    print(res)


            
    

