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 java.util.*;
import java.lang.*;
import java.io.*;

public class codeforces3 {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String d = sc.nextLine();
		String b = sc.nextLine();
		String c = sc.nextLine();
		
		int[] a1 = new int[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
		int v=0;
		for(char h='a'; h <='z'; h++){
		    a1[v] = d.length() - d.replaceAll(""+h, "").length();
		    v++;
		}

		int[] a2 = new int[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
	    v=0;
	    for(char h='a'; h <='z'; h++){
		    a2[v] = b.length() - b.replaceAll(""+h, "").length();
		    v++;
		}
        
        int[] a3 = new int[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
        v=0;
        for(char h='a'; h <='z'; h++){
		    a3[v] = c.length() - c.replaceAll(""+h, "").length();
		    v++;
		}
        
        int f=0;
        int g=0;
        while(!over(times(a2,f),a1)){
        	f++;
        }
        while(!over(times(a3,g),a1)){
        	g++;
        }
        int h = Math.max(f,g);
        int z=0;
        int p=0;
        int q=0;
        for(int x=0; x<=h; x++){
        	for(int y=0; y<=h-x; y++){
        		if((!over(plus(times(a2,x),times(a3,y)),a1)) && x+y>z){
        			z=x+y;
        			p=x;
        			q=y;
        		}
        	}
        }
        
        String fin = "";
        for(int x=0; x<p; x++){
        	String[] s = b.split("");
        	for(String ss: s){
        		fin += ss;
        		d = removeChar(d,ss);
        	}
        }
        
        for(int x=0; x<q; x++){
        	String[] t = c.split("");
        	for(String tt: t){
        		fin += tt;
        		d = removeChar(d,tt);
        	}
        }
        
        System.out.print(d+fin);
        
        sc.close();
	}
	
	public static int[] times(int[] a, int b){
		int[] g = new int[26];
		for(int c=0; c<26; c++){
			g[c] = b*a[c];
		}
		return g;
	}
	
	public static int[] plus(int[] a, int[] b){
		int[] g = new int[26];
		for(int c=0; c<26; c++){
			g[c] = a[c]+b[c];
		}
		return g;
	}
	
	public static boolean over(int[] a, int[] b){
		for(int c=0; c<26; c++){
			if(a[c]>b[c]){
				return true;
			}
		}
		return false;
	}
	
	public static String removeChar(String a, String b){
		return a.substring(0, a.indexOf(b)) + a.substring(a.indexOf(b)+1);
	}
}
