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.
import math,string,itertools,fractions,heapq,collections,re,array,bisect,copy
from itertools import chain, dropwhile, permutations, combinations
from collections import defaultdict, deque

# Guide:
#   1. construct complex data types while reading (e.g. graph adj list)
#   2. avoid any non-necessary time/memory usage
#   3. avoid templates and write more from scratch
#   4. switch to "flat" implementations

def VI(): return list(map(int,input().split()))
def I(): return int(input())
def LIST(n,m=None): return [0]*n if m is None else [[0]*m for i in range(n)]
def ELIST(n): return [[] for i in range(n)]
def MI(n=None,m=None): # input matrix of integers
    if n is None: n,m = VI()
    arr = LIST(n)
    for i in range(n): arr[i] = VI()
    return arr
def MS(n=None,m=None): # input matrix of strings
    if n is None: n,m = VI()
    arr = LIST(n)
    for i in range(n): arr[i] = input()
    return arr
def MIT(n=None,m=None): # input transposed matrix/array of integers
    if n is None: n,m = VI()
    a = MI(n,m)
    arr = LIST(m,n)
    for i,l in enumerate(a):
        for j,x in enumerate(l):
            arr[j][i] = x
    return arr


def run(n,x,l,r):
    s = 0
    curr = 1
    for i in range(n):
        skip = (l[i]-curr) // x
        s += r[i]-curr-skip*x+1
        curr = r[i]+1
    print(s)



def main(info=0):
    a,b,c = input(), input(), input()

    m = [a.count(chr(x+ord('a'))) for x in range(26)]

    def nin(s):
        n = 1000000
        for x in set(s):
            i = ord(x)-ord('a')
            n = min(n, m[i]//s.count(x))
        return n

    nb = nin(b)
    nc = nin(c)


    p = nc+nb
    minus = 0
    ii, jj = -1,-1
    while p-minus>0:
        for i in range(0,minus+1):
            j = minus-i
            if i>nb or j>nc:
                continue
            #print("start ",p,i,j,p-i-j)
            if nin((b*(nb-i))+(c*(nc-j)))>0:
                ii,jj = nb-i,nc-j
                #print("f ",ii,jj)
                break
        if ii >= 0:
            #print("w ",ii,jj)
            break
        minus += 1

    if ii<0:
        print(a)
    else:
        s = b*ii + c*jj
        for i,v in enumerate(m):
            char = chr(i+ord('a'))
            if char in s:
                m[i] -= s.count(char)
            s += char * m[i]
        print(s)



if __name__ == "__main__":
    main()
