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 functools import reduce


class GukziString:
    chars = 'abcdefghijklmnopqrstuvwxyz'

    def __init__(self, string=''):
        super(GukziString, self).__init__()
        for ch in GukziString.chars:
            setattr(self, ch, 0)
        for ch in string:
            setattr(self, ch, getattr(self, ch) + 1)

    def __sub__(self, other):
        ans = GukziString()
        for ch in GukziString.chars:
            setattr(ans, ch, getattr(self, ch) - getattr(other, ch))
        return ans

    def __mul__(self, number):
        ans = GukziString()
        for ch in GukziString.chars:
            setattr(ans, ch, getattr(self, ch) * number)
        return ans

    def __floordiv__(self, other):
        valid_chars = filter(lambda ch: getattr(other, ch) != 0, GukziString.chars)
        return reduce(lambda x, y: min(x, y), [getattr(self, ch) // getattr(other, ch) for ch in valid_chars])

    def __mod__(self, other):
        return self - other * (self // other)

    def __str__(self):
        ans = ''
        for ch in GukziString.chars:
            for i in range(getattr(self, ch)):
                ans += ch
        return ans


a_str = input()
b_str = input()
c_str = input()

a = GukziString(a_str)
b = GukziString(b_str)
c = GukziString(c_str)

left = 0
right = a // b + 1
max_sub = a // c
while right - left > 1:
    mid = (left + right) // 2
    if mid + (a - b * mid) // c > max_sub:
        left = mid
    else:
        right = mid

print(f'{b_str * left}{c_str * ((a - b * left) // c)}{(a - b * left) % c}')
