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.

Difficulty: MEDIUM_HARD

Solutions:
def kmp(s):
	p = [0] * len(s)
	idx = 0
	for i in range(1, len(s)):
		while idx > 0 and s[idx] != s[i]:
			idx = p[idx - 1]
		if s[idx] == s[i]:
			idx += 1
		p[i] = idx
	return idx

def solve(s, t, pref):
	f = [0, 0]
	f[0] = s.count('0')
	f[1] = s.count('1')
	i = 0
	ans = ''
	while f[0] or f[1]:
		if f[0] and (not f[1]):
			ans += '0'
			f[0] -= 1
		elif not f[0] and f[1]:
			ans += '1'
			f[1] -= 1
		elif t[i] == '0':
			ans += '0'
			f[0] -= 1
		else:
			ans += '1'
			f[1] -= 1
		i += 1
		if i == len(t):
			i = pref
	return ans
s = input()
t = input()
pref = kmp(t)
print(solve(s, t, pref))


import sys
input = sys.stdin.readline

def MP(s):
	a = [0] * (len(s) + 1)
	a[0] = -1
	j = -1
	for i in range(len(s)):
		while j >= 0 and s[i] != s[j]:
			j = a[j]
		j += 1
		a[i + 1] = j
	return a
s = input()[:-1]
t = input()[:-1]
cnt = [0, 0]
for char in s:
	cnt[int(char)] += 1
tbl = MP(t)
lap = len(t) - tbl[len(t)]
t = t[0:lap]
ans = []
while True:
	for char in t:
		if cnt[int(char)] > 0:
			ans.append(char)
			cnt[int(char)] -= 1
		else:
			break
	else:
		continue
	break
for i in range(cnt[0]):
	ans.append('0')
for i in range(cnt[1]):
	ans.append('1')
print(''.join(ans))


from collections import defaultdict as dd
import math

def nn():
	return int(input())

def li():
	return list(input())

def mi():
	return map(int, input().split())

def lm():
	return list(map(int, input().split()))
s = input()
t = input()
answer = []
s0 = 0
s1 = 0
t0 = 0
t1 = 0

def longestPrefixSuffix(s):
	n = len(s)
	lps = [0] * n
	l = 0
	i = 1
	while i < n:
		if s[i] == s[l]:
			l = l + 1
			lps[i] = l
			i = i + 1
		elif l != 0:
			l = lps[l - 1]
		else:
			lps[i] = 0
			i = i + 1
	res = lps[n - 1]
	return res
twindow = longestPrefixSuffix(t)
for i in range(len(s)):
	if s[i] == '0':
		s0 += 1
	else:
		s1 += 1
for i in range(len(t)):
	if t[i] == '0':
		t0 += 1
	else:
		t1 += 1
bad = 0
while s0 > 0 and s1 > 0:
	for i in range(len(t) - twindow):
		if t[i] == '0' and s0 == 0:
			bad = 1
			break
		if t[i] == '1' and s1 == 0:
			bad = 1
			break
		answer.append(t[i])
		if t[i] == '0':
			s0 -= 1
		if t[i] == '1':
			s1 -= 1
	if bad == 1:
		break
if s0 > 0:
	for k in range(s0):
		answer.append('0')
if s1 > 0:
	for k in range(s1):
		answer.append('1')
print(''.join(answer))


(s, t) = (input(), input())
(lenS, lenT) = (len(s), len(t))
tPrefix = [0] * (lenT + 1)
tPrefix[0] = -1
(i, j) = (0, -1)
while i < lenT:
	if j == -1 or t[i] == t[j]:
		i += 1
		j += 1
		tPrefix[i] = j
	else:
		j = tPrefix[j]
prefixLen = tPrefix[lenT]
sumS1 = sum(map(int, list(s)))
sumS0 = lenS - sumS1
r = []
it = 0
for i in range(lenS):
	if t[it] == '0':
		if sumS0 > 0:
			sumS0 -= 1
		else:
			break
	elif sumS1 > 0:
		sumS1 -= 1
	else:
		break
	r.append(t[it])
	it += 1
	if it == lenT:
		it = prefixLen
r.extend(['0'] * sumS0)
r.extend(['1'] * sumS1)
print(''.join(r))


s = input()
t = input()
b = 1
count = [0, 0]
count[0] += s.count('0')
count[1] += s.count('1')
kmpArr = [0 for x in range(len(t))]

def kmp():
	j = 0
	for i in range(1, len(t)):
		if t[j] == t[i]:
			kmpArr[i] = j + 1
			j += 1
		else:
			while j:
				j = kmpArr[j - 1]
				if t[j] == t[i]:
					kmpArr[i] = j + 1
					j += 1
					break
kmp()
text = ''
idex = 0
while 1:
	next = int(t[idex])
	if count[next] > 0:
		count[next] -= 1
		text += t[idex]
		idex += 1
		if idex > len(t) - 1:
			idex = kmpArr[-1]
	else:
		for i in range(count[0]):
			text += '0'
		for i in range(count[1]):
			text += '1'
		break
print(text)


from sys import stdin
s = stdin.readline().strip()
s1 = stdin.readline().strip()

def lps_array(pat):
	leng = 0
	i = 1
	M = len(pat)
	lps = [0] * M
	j = 0
	while i < M:
		if pat[i] == pat[leng]:
			leng += 1
			lps[i] = leng
			i += 1
		elif leng != 0:
			leng = lps[leng - 1]
		else:
			lps[i] = 0
			i += 1
	return lps[-1]
u = 0
z = 0
for i in range(len(s)):
	if s[i] == '1':
		u += 1
	else:
		z += 1
x = 0
t = True
ans = ''
y = lps_array(s1)
for i in range(len(s)):
	if s1[x] == '1' and u > 0:
		ans += '1'
		u -= 1
	elif s1[x] == '0' and z > 0:
		ans += '0'
		z -= 1
	elif u > 0:
		t = False
		ans += '1'
		u -= 1
	else:
		t = False
		ans += '0'
		z -= 1
	if t:
		x += 1
	if x == len(s1):
		x = y
print(ans)


flip = {'0': '1', '1': '0'}
(s, t) = (input(), input())
(n, m) = (len(s), len(t))
p = [0] * m
for i in range(1, m):
	g = p[i - 1]
	while g and t[i] != t[g]:
		g = p[g - 1]
	p[i] = g + int(t[i] == t[g])
s_cnt = {'0': s.count('0'), '1': s.count('1')}
t = t[:m - p[-1]]
res = [''] * n
for i in range(n):
	char = t[i % len(t)]
	char = char if s_cnt[char] > 0 else flip[char]
	s_cnt[char] -= 1
	res[i] = char
print(''.join(res))


import sys
s = sys.stdin.readline()[:-1]
t = sys.stdin.readline()[:-1]
(count0, count1) = (0, 0)
(n, m) = (len(s), len(t))
for i in range(n):
	if s[i] == '0':
		count0 += 1
		continue
	count1 += 1
lps = [0 for _ in range(m)]
(i, j) = (1, 0)
while i < m:
	if t[i] == t[j]:
		j += 1
		lps[i] = j
		i += 1
	elif j != 0:
		j = lps[j - 1]
	else:
		lps[i] = 0
		i += 1
x = lps[-1]
z = True
(i, j) = (0, 0)
ans = [0 for _ in range(n)]
while z:
	if t[i] == '1':
		if count1 > 0:
			ans[j] = '1'
			count1 -= 1
			i += 1
			j += 1
			if i == m:
				i = x
		else:
			z = False
	elif count0 > 0:
		ans[j] = '0'
		count0 -= 1
		i += 1
		j += 1
		if i == m:
			i = x
	else:
		z = False
while count0 > 0:
	ans[j] = '0'
	j += 1
	count0 -= 1
while count1 > 0:
	ans[j] = '1'
	j += 1
	count1 -= 1
print(''.join((x for x in ans)))


s = input()
t = input()

def kmp(text, pattern):
	pattern = list(pattern)
	shifts = [1] * (len(pattern) + 1)
	shift = 1
	for pos in range(len(pattern)):
		while shift <= pos and pattern[pos] != pattern[pos - shift]:
			shift += shifts[pos - shift]
		shifts[pos + 1] = shift
	return shifts
pf = kmp('', t)
sl = pf[-1]
tt = t[:sl]
ltt = len(tt)
s0 = sum([1 for v in s if v == '0'])
s1 = sum([1 for v in s if v == '1'])
cs = len(s)
ct = len(t)
ans = ''
i = 0
while len(ans) < len(s):
	v = tt[i]
	i += 1
	i %= ltt
	if v == '1':
		if s1 == 0:
			break
		s1 -= 1
		ans += '1'
	else:
		if s0 == 0:
			break
		s0 -= 1
		ans += '0'
ans += '0' * s0 + '1' * s1
print(ans)