Problem: The new camp by widely-known over the country Spring Programming Camp is going to start soon. Hence, all the team of friendly curators and teachers started composing the camp's schedule. After some continuous discussion, they came up with a schedule s, which can be represented as a binary string, in which the i-th symbol is '1' if students will write the contest in the i-th day and '0' if they will have a day off.

At the last moment Gleb said that the camp will be the most productive if it runs with the schedule t (which can be described in the same format as schedule s). Since the number of days in the current may be different from number of days in schedule t, Gleb required that the camp's schedule must be altered so that the number of occurrences of t in it as a substring is maximum possible. At the same time, the number of contest days and days off shouldn't change, only their order may change.

Could you rearrange the schedule in the best possible way?

Input

The first line contains string s (1 ⩽ |s| ⩽ 500 000), denoting the current project of the camp's schedule.

The second line contains string t (1 ⩽ |t| ⩽ 500 000), denoting the optimal schedule according to Gleb.

Strings s and t contain characters '0' and '1' only.

Output

In the only line print the schedule having the largest number of substrings equal to t. Printed schedule should consist of characters '0' and '1' only and the number of zeros should be equal to the number of zeros in s and the number of ones should be equal to the number of ones in s.

In case there multiple optimal schedules, print any of them.

Examples

Input


101101
110


Output


110110

Input


10010110
100011


Output


01100011


Input


10
11100


Output


01

Note

In the first example there are two occurrences, one starting from first position and one starting from fourth position.

In the second example there is only one occurrence, which starts from third position. Note, that the answer is not unique. For example, if we move the first day (which is a day off) to the last position, the number of occurrences of t wouldn't change.

In the third example it's impossible to make even a single occurrence.

Solution (in JAVA):

Solution:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D solver = new D();
        solver.solve(1, in, out);
        out.close();
    }

    static class D {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            String s = in.ns();
            String t = in.ns();
            int tn = t.length();
            if (tn > s.length()) {
                out.println(s);
                return;
            }
            int ns = 0;
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == '1')
                    ns++;
            }
            int ns0 = s.length() - ns;
            int[] cnt = new int[tn + 1];
            int[] cnt0 = new int[tn + 1];
            for (int i = 0; i < tn; i++) {
                cnt[i + 1] = cnt[i];
                cnt0[i + 1] = cnt0[i];
                if (t.charAt(i) == '1')
                    cnt[i + 1]++;
                else
                    cnt0[i + 1]++;
            }
            int ans = 0;
            int rem1 = 0;
            int rem0 = 0;
            int pref = 0;
            int[] z = StringUtil.z(t);
            for (int i = 0; i < tn; i++) {
                if (z[i] == tn - i) {
                    int rep;

                    if (cnt[i] == 0 && cnt0[i] == 0) {
                        if (cnt[tn] == 0)
                            rep = ns0 / cnt0[tn];
                        else if (cnt0[tn] == 0)
                            rep = ns / cnt[tn];
                        else
                            rep = Math.min(ns / cnt[tn], ns0 / cnt0[tn]);
                        if (rep > ans && tn * rep <= s.length()) {
                            ans = rep;
                            pref = i;
                            rem1 = ns - cnt[tn] * ans;
                            rem0 = ns0 - cnt0[tn] * ans;
                        }
                        continue;
                    } else if (cnt[i] == 0) {
                        rep = (ns0 - cnt0[tn] + cnt0[i]) / cnt0[i];
                    } else if (cnt0[i] == 0) {
                        rep = (ns - cnt[tn] + cnt[i]) / cnt[i];
                    } else
                        rep = Math.min((ns - cnt[tn] + cnt[i]) / cnt[i], (ns0 - cnt0[tn] + cnt0[i]) / cnt0[i]);
                    if (rep > ans && tn - i + i * rep <= s.length()) {
                        ans = rep;
                        pref = i;
                        rem1 = ns - cnt[tn] + cnt[i] - cnt[i] * ans;
                        rem0 = ns0 - cnt0[tn] + cnt0[i] - cnt0[i] * ans;
                    }
                }
            }
            //System.out.println(" ans = " + ans);
            if (rem1 < 0 || rem0 < 0)
                throw new RuntimeException();

            if (ans == 0) {
                out.println(s);
            } else {
                if (pref > 0) {
                    String sub = t.substring(0, pref);
                    for (int i = 0; i < ans - 1; i++) {
                        out.print(sub);
                    }
                    out.print(t);
                } else {
                    for (int i = 0; i < ans; i++) {
                        out.print(t);
                    }
                }

                for (int i = 0; i < rem1; i++) {
                    out.print('1');
                }
                for (int i = 0; i < rem0; i++) {
                    out.print('0');
                }
                out.println();
            }

        }

    }

    static class StringUtil {
        public static int[] z(String s) {
            int[] z = new int[s.length()];
            int l = 0, r = 0;
            int j;
            z[0] = s.length();
            for (int i = 1; i < s.length(); i++)
                if (i > r) {
                    for (j = 0; ((j + i) < s.length()) && (s.charAt(i + j) == s.charAt(j)); j++) ;
                    z[i] = j;
                    l = i;
                    r = i + j - 1;
                } else if (z[i - l] < r - i + 1)
                    z[i] = z[i - l];
                else {
                    for (j = 1; ((j + r) < s.length()) && (s.charAt(r + j) == s.charAt(r - i + j)); j++) ;
                    z[i] = r - i + j;
                    l = i;
                    r = r + j - 1;
                }
            return z;
        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String ns() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

    }
}