AtCoder Beginner Contest 076 - Dubious Document 2

E869120 found a chest which is likely to contain treasure.

However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters.

He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with ?.  
One more thing he found is a sheet of paper with the following facts written on it:  
 - Condition 1: The string S contains a string T as a contiguous substring.
 - Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1.
Print the string S.

If such a string does not exist, print UNRESTORABLE.  

-----Constraints-----
 - 1 \leq |S'|, |T| \leq 50
 - S' consists of lowercase English letters and ?.
 - T consists of lowercase English letters.

-----Input-----
Input is given from Standard Input in the following format:
S
T'

-----Output-----
Print the string S.

If such a string does not exist, print UNRESTORABLE instead.  

-----Sample Input-----
?tc????
coder

-----Sample Output-----
atcoder

There are 26 strings that satisfy Condition 1: atcoder, btcoder, ctcoder,..., ztcoder.
Among them, the lexicographically smallest is atcoder, so we can say S = atcoder.

Source: atcoder | Difficulty: EASY


Solutions:
import re
s_dash = input()
t = input()
for i in reversed(range(len(s_dash) - len(t) + 1)):
	matchobj = re.match(s_dash[i:i + len(t)].replace('?', '[a-z]'), t)
	if matchobj:
		_s = list(s_dash)
		_s[i:i + len(t)] = t
		print(''.join(_s).replace('?', 'a'))
		exit()
print('UNRESTORABLE')
exit()


s = input()
t = input()
s = s[::-1]
t = t[::-1]
len_s = len(s)
len_t = len(t)
for i in range(len_s - len_t + 1):
	flag = True
	for j in range(len_t):
		if s[i + j] != t[j] and s[i + j] != '?':
			flag = False
			break
	if flag:
		print((s[0:i] + t + s[i + len_t:len_s]).replace('?', 'a')[::-1])
		exit()
print('UNRESTORABLE')


s = input()
t = input()
n = len(t)
m = len(s)
c = 'z' * m
for i in range(m - n + 1):
	if all((j in (t[k], '?') for (k, j) in enumerate(s[i:n + i]))):
		c = min(c, s[:i] + t + s[i + n:])
print('UNRESTORABLE' if c == 'z' * m else c.replace('?', 'a'))


S_p = input()
T = input()
k = []
for i in range(len(S_p) - len(T) + 1):
	S_sub = S_p[i:i + len(T)]
	if all((s in (t, '?') for (s, t) in zip(S_sub, T))):
		k.append(i)
if k:
	S = S_p[:k[-1]] + T + S_p[k[-1] + len(T):]
	print(S.replace('?', 'a'))
else:
	print('UNRESTORABLE')


S = input()
T = input()
s = len(S)
t = len(T)
ans = 'UNRESTORABLE'
for i in range(s - t + 1):
	for j in range(t):
		(T[j], S[i + j])
		if T[j] == S[i + j] or S[i + j] == '?':
			continue
		else:
			break
	else:
		ans = S[:i] + T + S[i + t:]
		ans = ans.replace('?', 'a')
print(ans)


s = input()
n = len(s)
t = input()
m = len(t)
ans = []
for i in range(n - m + 1):
	for j in range(m):
		if s[i + j] not in [t[j], '?']:
			break
		elif j == m - 1:
			res = s[:i] + t + s[i + m:]
			ans.append(res.replace('?', 'a'))
if not ans:
	ans.append('UNRESTORABLE')
print(min(ans))


s = input()
t = input()
lt = len(t)
ans = []
for i in range(len(s) - lt + 1):
	cnt = 0
	n = 0
	while n < lt:
		if s[i + n] == '?':
			cnt += 1
		elif s[i + n] == t[n]:
			cnt += 1
		n += 1
	if cnt == lt:
		ans.append(list(s[:i] + t + s[i + lt:]))
if len(ans) != 0:
	for a in ans:
		for i in range(len(a)):
			if a[i] == '?':
				a[i] = 'a'
	ans.sort()
	print(*ans[0], sep='')
else:
	print('UNRESTORABLE')


S = input()
T = input()
s = len(S)
t = len(T)
A = []
for i in range(s - t + 1):
	if all((S[i + j] == T[j] or S[i + j] == '?' for j in range(t))):
		A.append(S[:i] + T + S[i + t:])
A = [a.replace('?', 'a') for a in A]
if len(A) == 0:
	print('UNRESTORABLE')
else:
	print(min(A))


import re
Srd = ''.join(reversed(input()))
T = input()
Tr = ''.join(reversed(T))
Trd = ''.join(['[{}?]'.format(x) for x in Tr])
S = ''.join(reversed(re.sub(Trd, Tr, Srd, 1))).replace('?', 'a')
if S.count(T):
	print(S)
else:
	print('UNRESTORABLE')


import re
s = input()
t = input()
s = s.replace('?', '.')[::-1]
t = t[::-1]
for i in range(len(s) - len(t) + 1):
	if re.match(s[i:i + len(t)], t):
		s = s[:i].replace('.', 'a') + t + s[i + len(t):].replace('.', 'a')
		print(s[::-1])
		break
else:
	print('UNRESTORABLE')


import sys
sp = input()
t = input()
m = len(sp)
n = len(t)
for i in range(m - n, -1, -1):
	cand = sp[:i].replace('?', 'a') + t + sp[i + n:].replace('?', 'a')
	for (j, w) in enumerate(t):
		if sp[j + i] != w and sp[j + i] != '?':
			break
	else:
		print(cand)
		sys.exit()
print('UNRESTORABLE')


import re
S_ = input()
T = input()
Srev = ''.join(reversed(S_))
Trev = ''.join(reversed(T))
pattern = ''.join(['[{}?]'.format(t) for t in Trev])
ans = re.sub(pattern, Trev, Srev, count=1)
ans = ''.join(reversed(ans.replace('?', 'a')))
if ans.count(T):
	print(ans)
else:
	print('UNRESTORABLE')


s = input()
t = input()
l = []
for i in range(len(s) - len(t) + 1):
	for j in range(i, i + len(t)):
		if s[j] != '?' and s[j] != t[j - i]:
			break
	else:
		l.append(s[:i] + t + s[i + len(t):])
if len(l) == 0:
	print('UNRESTORABLE')
	return
l.sort()
print(l[0].replace('?', 'a'))


import re
S_ = input()
T = input()
S_ = S_[::-1]
T = T[::-1]
t = ''
for c in T:
	t += '[?' + c + ']'
regex = re.compile(t)
(S, cnt) = regex.subn(T, S_, count=1)
if cnt:
	S = S.replace('?', 'a')
	print(S[::-1])
else:
	print('UNRESTORABLE')


s = input()[::-1]
t = input()[::-1]
(sl, tl) = (len(s), len(t))
for i in range(sl - tl + 1):
	for j in range(tl):
		if s[i + j] != '?' and s[i + j] != t[j]:
			break
	else:
		print((s[:i] + t + s[i + tl:]).replace('?', 'a')[::-1])
		break
else:
	print('UNRESTORABLE')


(s, t) = (input(), input())
ls = len(s)
lt = len(t)
ans = ''
for i in range(ls - lt + 1)[::-1]:
	c = 0
	for j in range(lt):
		if s[i + j] == t[j] or s[i + j] == '?':
			c += 1
	if c == lt:
		ans = s[:i] + t + s[i + lt:]
		print(ans.replace('?', 'a'))
		break
else:
	print('UNRESTORABLE')


s = input()[::-1]
t = input()[::-1]
l = len(t)
for i in range(len(s) - l + 1):
	f = 1
	for (j, k) in enumerate(s[i:i + l]):
		if '?' != k != t[j]:
			f = 0
			break
	if f:
		s = s[:i] + t + s[i + l:]
		print(s.replace('?', 'a')[::-1])
		exit()
print('UNRESTORABLE')


s = list(input())
t = list(input())
(ls, lt) = (len(s), len(t))
s.reverse()
t.reverse()
for i in range(ls):
	for j in range(lt):
		if i + j >= ls:
			break
		if s[i + j] != '?' and s[i + j] != t[j]:
			break
	else:
		for j in range(lt):
			s[i + j] = t[j]
		s = [x if x != '?' else 'a' for x in s]
		s.reverse()
		ans = ''.join(s)
		break
else:
	ans = 'UNRESTORABLE'
print(ans)


S = input()
T = input()
for k in range(len(S) - len(T), -1, -1):
	f = 1
	for i in range(len(T)):
		if S[k + i] != '?' and S[k + i] != T[i]:
			f = 0
			break
	if f == 1:
		print(S[:k].replace('?', 'a') + T + S[k + len(T):].replace('?', 'a'))
		exit(0)
print('UNRESTORABLE')


S = input()
T = input()
ans_list = []
for i in range(len(S) - len(T) + 1):
	X = S[i:i + len(T)]
	isOK = True
	for j in range(len(T)):
		if X[j] == '?' or X[j] == T[j]:
			pass
		else:
			isOK = False
			break
	if isOK:
		ans = S[:i] + T + S[i + len(T):]
		ans = ans.replace('?', 'a')
		ans_list.append(ans)
if len(ans_list) < 1:
	print('UNRESTORABLE')
else:
	ans_list.sort()
	print(ans_list[0])


import re
s = input().replace('?', '.')
t = input()
lst = []
for i in range(len(s) - len(t) + 1):
	if re.match(s[i:i + len(t)], t):
		lst.append(s[:i].replace('.', 'a') + t + s[i + len(t):].replace('.', 'a'))
if lst:
	print(min(lst))
else:
	print('UNRESTORABLE')


s = input()
t = input()
s_len = len(s)
t_len = len(t)
for i in range(s_len - t_len, -1, -1):
	for j in range(t_len):
		if s[i + j] != t[j] and s[i + j] != '?':
			break
	else:
		print((s[:i] + t + s[i + t_len:]).replace('?', 'a'))
		exit()
print('UNRESTORABLE')


import re
S = input().replace('?', '.')
T = input()
n = len(S)
m = len(T)
j = -1
for i in range(n - m, -1, -1):
	if re.match(S[i:i + m], T):
		j = i
		break
if j == -1:
	print('UNRESTORABLE')
else:
	ans = ''.join(['a' if t == '.' else t for t in S])
	ans = ans[:j] + T + ans[j + m:]
	print(ans)


import math
from math import gcd, pi, sqrt
INF = float('inf')
import sys
sys.setrecursionlimit(10 ** 6)
import itertools
from collections import Counter, deque

def i_input():
	return int(input())

def i_map():
	return list(map(int, input().split()))

def i_list():
	return list(i_map())

def i_row(N):
	return [i_input() for _ in range(N)]

def i_row_list(N):
	return [i_list() for _ in range(N)]

def s_input():
	return input()

def s_map():
	return input().split()

def s_list():
	return list(s_map())

def s_row(N):
	return [s_input for _ in range(N)]

def s_row_str(N):
	return [s_list() for _ in range(N)]

def s_row_list(N):
	return [list(s_input()) for _ in range(N)]

def main():
	s = input()
	t = input()
	s_len = len(s)
	t_len = len(t)
	flg = False
	for i in range(s_len - t_len, -1, -1):
		flg = True
		for j in range(t_len):
			if s[i + j] != t[j] and s[i + j] != '?':
				flg = False
				break
		if flg == True:
			trial = i
			break
	if flg == False:
		print('UNRESTORABLE')
		return
	ans = ''
	for i in s[:trial]:
		if i == '?':
			ans = ans + 'a'
		else:
			ans = ans + i
	ans = ans + t
	for i in s[trial + t_len:]:
		if i == '?':
			ans = ans + 'a'
		else:
			ans = ans + i
	print(ans)

def __starting_point():
	main()
__starting_point()


import re
s = input().replace('?', '.')
t = input()
for i in range(len(s) - len(t), -1, -1):
	if re.match(s[i:i + len(t)], t):
		s = s[:i] + t + s[i + len(t):]
		s = s.replace('.', 'a')
		print(s)
		exit(0)
print('UNRESTORABLE')


sd = input()
t = input()
n = len(sd)
m = len(t)
s = []
for i in range(n - m, -1, -1):
	ans = sd[i:i + m]
	for j in range(m + 1):
		if j == m:
			print((sd[:i] + t + sd[i + len(t):]).replace('?', 'a'))
			exit()
		if ans[j] == '?':
			continue
		elif ans[j] != t[j]:
			break
print('UNRESTORABLE')


def equ(s, t):
	for i in range(len(t)):
		if t[i] != s[i] != '?':
			return False
	return True
S1 = input()
T = input()
l = len(S1)
m = len(T)
S = ''
for i in range(l - m, -1, -1):
	if equ(S1[i:i + m], T):
		S = (S1[:i] + T + S1[i + m:]).replace('?', 'a')
		break
print(S if S != '' else 'UNRESTORABLE')


import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float('inf')
IINF = 10 ** 18

def solve():
	s = str(stdin.readline().rstrip())
	t = str(stdin.readline().rstrip())
	anss = []
	for i in range(len(s) - len(t) + 1):
		test = s[i:len(t) + i]
		flag = True
		for j in range(len(t)):
			if test[j] != '?' and test[j] != t[j]:
				flag = False
		if flag == True:
			ans = s[0:i] + t + s[i + len(t):]
			ans = ans.replace('?', 'a')
			anss.append(ans)
	if len(anss) == 0:
		print('UNRESTORABLE')
		return
	anss.sort()
	print(anss[0])

def __starting_point():
	solve()
__starting_point()


Sp = input()
T = input()
S = []
for i in range(len(Sp) - len(T) + 1):
	for j in range(len(T)):
		if Sp[i + j] not in ('?', T[j]):
			break
	else:
		tmp = Sp[:i] + T + Sp[i + len(T):]
		S.append(tmp.replace('?', 'a'))
print(min(S) if S else 'UNRESTORABLE')


S = input()
T = input()
ss = list()
for n in range(len(S) - len(T) + 1):
	for m in range(len(T)):
		if S[n + m] not in ['?', T[m]]:
			break
	else:
		ss.append((S[:n] + T + S[n + len(T):]).replace('?', 'a'))
if len(ss) == 0:
	print('UNRESTORABLE')
else:
	print(min(ss))


S = input()
T = input()
for i in range(len(S) - len(T), -1, -1):
	for (cs, ct) in zip(S[i:i + len(T)], T):
		if not (cs == '?' or cs == ct):
			break
	else:
		S = S[:i] + T + S[i + len(T):]
		S = S.replace('?', 'a')
		print(S)
		break
else:
	print('UNRESTORABLE')


S = input()
T = input()
(len_S, len_T) = (len(S), len(T))
ans = []
for i in range(len_S - len_T + 1):
	f = True
	for j in range(len_T):
		if S[i + j] != T[j] and S[i + j] != '?':
			f = False
			break
	if f:
		s = S[:i] + T + S[i + j + 1:]
		ans.append(s.replace('?', 'a'))
if len(ans) == 0:
	print('UNRESTORABLE')
else:
	ans.sort()
	print(ans[0])


s = input()
t = input()
ls = len(s)
lt = len(t)
ans = 0
for i in range(ls - lt + 1):
	x = s[:i] + t + s[i + lt:ls]
	f = 1
	for j in range(ls):
		if s[j] == '?':
			continue
		if s[j] != x[j]:
			f = 0
			break
	if f:
		p = ''
		for k in range(ls):
			if x[k] == '?':
				p += 'a'
			else:
				p += x[k]
		ans = p
if ans:
	print(p)
else:
	print('UNRESTORABLE')


S = str(input())
T = str(input())
ls = len(S)
lt = len(T)
ans = ''
loc = None
for i in range(ls - lt, -1, -1):
	flag = 0
	for j in range(lt):
		if not (S[i + j] == T[j] or S[i + j] == '?'):
			flag = 1
			break
	if flag == 0:
		loc = i
		break
if loc == None:
	print('UNRESTORABLE')
else:
	i = 0
	while i < ls:
		if i == loc:
			ans += T
			i += lt
		elif S[i] == '?':
			ans += 'a'
			i += 1
		else:
			ans += S[i]
			i += 1
	print(ans)


s = input()
t = input()
l = []
for i in range(len(s) - len(t) + 1):
	f = 0
	u = s[i:len(t) + i]
	for j in range(len(t)):
		if u[j] != t[j] and u[j] != '?':
			f = 1
	if f == 0:
		l.append((s[:i] + t + s[len(t) + i:]).replace('?', 'a'))
if l:
	print(sorted(l)[0])
else:
	print('UNRESTORABLE')


S = input()
T = input()
n = len(S)
m = len(T)
ans = 'UNRESTORABLE'
for i in range(n - m + 1):
	for j in range(m):
		if T[j] == S[i + j] or S[i + j] == '?':
			continue
		else:
			break
	else:
		ans = S[0:i] + T + S[i + m:]
		ans = ans.replace('?', 'a')
print(ans)


S = input()
T = input()
ans = ''
for i in range(len(S) - len(T) + 1):
	flag = True
	for (s, t) in zip(S[i:], T):
		if s != '?' and s != t:
			flag = False
			break
	if flag:
		ans = S[:i] + T + S[i + len(T):]
if ans != '':
	print(ans.replace('?', 'a'))
else:
	print('UNRESTORABLE')


s = input()
t = input()
n = len(s)
m = len(t)
ans = []
for i in range(n - m + 1):
	c = 0
	for j in range(m):
		if s[i + j] == '?' or s[i + j] == t[j]:
			c += 1
	if c == m:
		s_ = s[0:i] + t + s[i + m:]
		s_ = s_.replace('?', 'a')
		ans.append(s_)
if len(ans) > 0:
	print(sorted(ans)[0])
else:
	print('UNRESTORABLE')


s_ = input()
t = input()
for (i, s_i) in tuple(zip(range(len(s_) - len(t) + 1), [s_[x:x + len(t)] for x in range(len(s_) - len(t) + 1)]))[::-1]:
	if all((s_i_c == '?' or s_i_c == t[j] for (j, s_i_c) in enumerate(s_i))):
		print((s_[:i] + t + s_[i + len(t):]).replace('?', 'a'))
		exit()
print('UNRESTORABLE')


import re
(s, t) = (input().replace(*'?.'), input())
(l, m) = (len(s), len(t))
can = []
for i in range(l - m + 1):
	if re.match(s[i:i + m], t):
		can += ((s[:i] + t + s[i + m:]).replace(*'.a'),)
print(min(can) if can else 'UNRESTORABLE')


S = input()
t = input()
n = len(S)
m = len(t)
for i in range(n - m, -1, -1):
	t_ = S[i:i + m]
	for j in range(m + 1):
		if j == m:
			print((S[:i] + t + S[i + m:]).replace('?', 'a'))
			exit()
		if t_[j] == '?':
			continue
		elif t_[j] != t[j]:
			break
print('UNRESTORABLE')


S = list(input())
T = list(input())
s = len(S)
t = len(T)
for i in range(s - t, -1, -1):
	ss = S[i:i + t]
	for j in range(t):
		if ss[j] != '?' and ss[j] != T[j]:
			break
	else:
		for j in range(t):
			if ss[j] == '?':
				S[i + j] = T[j]
		break
else:
	print('UNRESTORABLE')
	return
for i in range(s):
	if S[i] == '?':
		S[i] = 'a'
print(''.join(S))


import re
_S = input()
T = input()
lenS = len(_S)
lenT = len(T)
if lenT > lenS:
	print('UNRESTORABLE')
else:
	S = re.split('([?' + '][?'.join(T[::-1]) + '])', _S[::-1])
	if len(S) == 1:
		print('UNRESTORABLE')
	else:
		S[1] = T[::-1]
		S = ''.join(S)
		print(S[::-1].replace('?', 'a'))


import re
S = input().replace('?', '.')
T = input()
for i in range(len(S) - len(T), -1, -1):
	if re.match(S[i:i + len(T)], T):
		S = S.replace('.', 'a')
		print(S[:i] + T + S[i + len(T):])
		exit()
print('UNRESTORABLE')


import copy
s = list(input())
t = list(input())
(t1, t2) = (copy.deepcopy(s), copy.deepcopy(s))
ok = []
ch = True
if ch:
	for i in range(len(s) - len(t) + 1):
		count = 0
		for j in range(len(t)):
			if s[i + j] == t[j] or s[i + j] == '?':
				count += 1
		if count == len(t):
			ok.append(i)
if len(ok) == 0:
	print('UNRESTORABLE')
	ch = False
else:
	for i in range(len(t)):
		t1[ok[0] + i] = t[i]
	for i in range(len(t)):
		t2[ok[-1] + i] = t[i]
if ch:
	for i in range(len(t1)):
		if t1[i] == '?':
			t1[i] = 'a'
		if t2[i] == '?':
			t2[i] = 'a'
	(an1, an2) = ('', '')
	for i in t1:
		an1 += i
	for i in t2:
		an2 += i
	print(min(an1, an2))


s = list(input())
t = list(input())
x = len(s)
y = len(t)
for i in range(x - y + 1):
	for j in range(y):
		if s[x - y - i + j] != t[j] and s[x - y - i + j] != '?':
			break
	else:
		s[x - y - i:x - i] = t
		print(''.join(s).replace('?', 'a'))
		exit()
print('UNRESTORABLE')


s_ = input()
t_ = input()
s = [c for c in s_]
t = [c for c in t_]
n = len(s)
m = len(t)
for i in reversed(list(range(m - 1, n))):
	replaced = 0
	if s[i] == t[-1] or s[i] == '?':
		k = i - 1
		replace = 1
		for j in reversed(list(range(m - 1))):
			if s[k] == t[j] or s[k] == '?':
				if j == 0:
					replace = 1
					break
			else:
				replace = 0
				break
			k -= 1
		if replace:
			k = i
			for j in reversed(list(range(m))):
				s[k] = t[j]
				k -= 1
			replaced = 1
	if replaced:
		break
if n < m:
	replaced = 0
if replaced:
	for i in range(n):
		if s[i] == '?':
			s[i] = 'a'
	print(''.join(s))
else:
	print('UNRESTORABLE')


S = input()
T = input()
s_len = len(S)
t_len = len(T)
res = []
init_K = '?' * s_len
for i in range(s_len - t_len + 1):
	K = list(init_K[:i] + T + init_K[i + t_len:])
	for j in range(s_len):
		if S[j] == '?' or S[j] == K[j]:
			pass
		elif K[j] == '?':
			K[j] = S[j]
		else:
			break
	else:
		res.append(''.join(K).replace('?', 'a'))
if res:
	res.sort()
	print(res[0])
else:
	print('UNRESTORABLE')


import re
S = input()
T = input()
for i in range(len(S) - len(T), -1, -1):
	if re.fullmatch(S[i:i + len(T)].replace('?', '.'), T):
		print((S[:i] + T + S[i + len(T):]).replace('?', 'a'))
		break
else:
	print('UNRESTORABLE')


import math
sd = list(input())
t = list(input())
dic = []
slen = len(sd)
tlen = len(t)
for i in range(slen - tlen + 1):
	for j in range(tlen):
		if not (t[j] == sd[i + j] or sd[i + j] == '?'):
			break
	else:
		s = sd[:i] + t + sd[i + tlen:]
		for k in range(len(s)):
			if s[k] == '?':
				s[k] = 'a'
		dic.append(''.join(s))
if len(dic) == 0:
	print('UNRESTORABLE')
	return
print(sorted(dic)[0])


(S, T) = (input(), input())
(l, m) = (len(S), len(T))
for i in range(l - m + 1):
	if all((c in '?' + d for (c, d) in zip(S[-i - m:], T))):
		S = S.replace('?', 'a')
		print(S[:-i - m] + T + S[l - i:])
		quit()
print('UNRESTORABLE')


S = input()
T = input()
n = len(S)
m = len(T)
flag = 0
ans = 'UNRESTORABLE'
for i in range(n - m + 1):
	for j in range(m):
		if S[i + j] != '?' and S[i + j] != T[j]:
			break
	else:
		S2 = S[:i] + T + S[i + m:]
		ans = S2.replace('?', 'a')
print(ans)


S = input()
T = input()
s_l = len(S)
t_l = len(T)
t = list(T)
ans = 'UNRESTORABLE'
for i in range(s_l - t_l + 1):
	s = list(S[i:i + t_l])
	count = 0
	for (a, b) in zip(s, t):
		if a == b or a == '?':
			count += 1
			if count == t_l:
				ans = S[:i] + T + S[i + t_l:]
		else:
			break
print(ans.replace('?', 'a'))


S = list(input())
T = input()
candidate = []
ans = True
for i in range(len(S)):
	flag = True
	for j in range(len(T)):
		if i + j >= len(S):
			flag = False
			break
		if S[i + j] == '?' or S[i + j] == T[j]:
			pass
		else:
			flag = False
			break
	if flag:
		candidate.append(i)
		ans = False
if ans:
	print('UNRESTORABLE')
	return
i = candidate[-1]
for tmp in range(i, i + len(T)):
	S[tmp] = T[tmp - i]
for i in range(len(S)):
	if S[i] == '?':
		S[i] = 'a'
print(''.join(S))


s = input()
t = input()
l = len(s)
m = len(t)
L = []
for i in range(l - m + 1):
	if all([s[i + j] == '?' or s[i + j] == t[j] for j in range(m)]):
		L.append(i)
if L:
	k = max(L)
	print((s[:k] + t + s[k + m:]).replace('?', 'a'))
else:
	print('UNRESTORABLE')


s = input()
t = input()
u = len(t)
for i in range(len(s) - u, -1, -1):
	for j in range(u):
		if s[i + j] != '?' and s[i + j] != t[j]:
			break
	else:
		print('{}{}{}'.format(s[:i], t, s[i + u:]).replace('?', 'a'))
		break
else:
	print('UNRESTORABLE')


s = input()
t = input()
n = len(s)
m = len(t)
ans = -1
for i in range(n - m + 1):
	sum = 0
	for j in range(m):
		if s[i + j] == t[j] or s[i + j] == '?':
			sum += 1
	if sum == m:
		ans = i
if ans == -1:
	print('UNRESTORABLE')
else:
	s = s[:ans] + t + s[ans + m:]
	b = s.replace('?', 'a')
	print(b)


ss = list(input())
t = list(input())
ans = 'UNRESTORABLE'
for i in range(len(ss) - len(t), -1, -1):
	flag = True
	for j in range(i, i + len(t)):
		if ss[j] != t[j - i] and ss[j] != '?':
			flag = False
			break
	if flag:
		ss[i:i + len(t)] = t
		ans = ''.join(ss).replace('?', 'a')
		break
print(ans)


s = input()
t = input()
a = []
for i in range(len(s) - len(t) + 1):
	f = True
	for j in range(len(t)):
		if s[i + j] != '?' and s[i + j] != t[j]:
			f = False
	if f == True:
		a.append(i)
s = s.replace('?', 'a')
if len(a) != 0:
	print(s[:a[-1]] + t + s[a[-1] + len(t):])
else:
	print('UNRESTORABLE')


import sys
stdin = sys.stdin

def ns():
	return stdin.readline().rstrip()

def ni():
	return int(stdin.readline().rstrip())

def nm():
	return list(map(int, stdin.readline().split()))

def nl():
	return list(map(int, stdin.readline().split()))

def can_replace(S, T):
	cnt = 0
	for (s, t) in zip(S, T):
		if s == t or s == '?':
			cnt += 1
	if cnt == len(S):
		return True
	else:
		return False

def main():
	S = list(ns()[::-1])
	T = list(ns()[::-1])
	for i in range(len(S) - len(T) + 1):
		if can_replace(S[i:i + len(T)], T):
			S[i:i + len(T)] = T
			S = ''.join(S)
			print(S.replace('?', 'a')[::-1])
			return
	print('UNRESTORABLE')

def __starting_point():
	main()
__starting_point()


def main():
	S = input()
	T = input()
	N = len(S)
	M = len(T)
	for i in range(N - M + 1)[::-1]:
		if all((s == t or s == '?' for (s, t) in zip(S[i:i + M], T))):
			return print(S[:i].replace('?', 'a') + T + S[i + M:].replace('?', 'a'))
	print('UNRESTORABLE')
main()


import re
s = input()
t = input()
for i in range(len(s) - len(t), -1, -1):
	for j in range(len(t)):
		if s[i + j] != '?' and s[i + j] != t[j]:
			break
	else:
		s = s[:i] + t + s[i + len(t):]
		break
else:
	print('UNRESTORABLE')
	exit(0)
res = s.replace('?', 'a')
print(res)


S = input()
T = input()
ans = 'UNRESTORABLE'
for i in range(len(S) - len(T), -1, -1):
	for j in range(len(T)):
		if S[i + j] != '?' and S[i + j] != T[j]:
			break
	else:
		ans = S[:i].replace('?', 'a') + T + S[i + len(T):].replace('?', 'a')
		break
print(ans)


s = input()[::-1]
t = input()[::-1]
x = ''
for i in range(0, len(s) - len(t) + 1):
	if x == '':
		x = s[i:i + len(t)]
	else:
		x = x[1:] + s[i + len(t) - 1]
	flag = True
	for j in range(len(t)):
		if x[j] == '?' or x[j] == t[j]:
			continue
		else:
			flag = False
	if flag:
		s = (s[:i] + t + s[i + len(t):])[::-1]
		print(s.replace('?', 'a'))
		return
print('UNRESTORABLE')


import sys
import math
from collections import defaultdict
from collections import deque
sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda : sys.stdin.readline().strip()
NI = lambda : int(input())
NMI = lambda : map(int, input().split())
NLI = lambda : list(NMI())
SI = lambda : input()

def main():
	S = SI()
	T = SI()
	ls = len(S)
	lt = len(T)
	R = []
	for i in range(ls - lt + 1):
		SS = S[i:i + lt]
		is_ok = True
		for (s, t) in zip(SS, T):
			if s != '?' and s != t:
				is_ok = False
		if not is_ok:
			continue
		r = ''
		for (j, s) in enumerate(S):
			if j == i:
				r += T
			elif i < j < i + lt:
				pass
			elif s == '?':
				r += 'a'
			else:
				r += s
		R.append(r)
	R.sort()
	if R:
		print(R[0])
	else:
		print('UNRESTORABLE')

def __starting_point():
	main()
__starting_point()


s = list(input())[::-1]
t = list(input())[::-1]
if len(s) < len(t):
	print('UNRESTORABLE')
else:
	for i in range(len(s) - len(t) + 1):
		for j in range(len(t)):
			if s[i + j] not in ['?', t[j]]:
				break
		else:
			s[i:i + len(t)] = t
			break
	else:
		print('UNRESTORABLE')
		exit()
	print(''.join(s[::-1]).replace('?', 'a'))


S = input()
T = input()
if len(S) < len(T):
	print('UNRESTORABLE')
	return
ind = None
for i in range(len(S) - len(T) + 1):
	for j in range(len(T)):
		if S[i + j] == '?':
			continue
		elif S[i + j] == T[j]:
			continue
		else:
			break
	else:
		ind = i
if ind == None:
	print('UNRESTORABLE')
else:
	ans = list(S)
	for i in range(ind, ind + len(T)):
		ans[i] = T[i - ind]
	for i in range(len(ans)):
		if ans[i] == '?':
			ans[i] = 'a'
	print(''.join(ans))


(s, t) = [s.strip() for s in open(0)]
ans = 'UNRESTORABLE'
for i in range(len(s) - len(t), -1, -1):
	for j in range(len(t)):
		if s[i + j] != '?' and s[i + j] != t[j]:
			break
	else:
		ans = s[:i] + t + s[i + len(t):]
		ans = ans.replace('?', 'a')
		break
print(ans)


S = input()
T = input()
t = len(T)
for i in range(len(S) - t, -1, -1):
	for j in range(t):
		k = S[i + j]
		if k != T[j] and k != '?':
			break
	else:
		print((S[:i] + T + S[i + t:] + '').replace('?', 'a'))
		exit()
print('UNRESTORABLE')


S = input()
T = input()
for i in reversed(range(len(S) - len(T) + 1)):
	st = S[i:i + len(T)]
	t = 1
	for j in range(len(T)):
		if st[j] != '?' and st[j] != T[j]:
			t = 0
			break
	if t == 1:
		S = S.replace('?', 'a')
		print(S[:i] + T + S[i + len(T):])
		exit()
print('UNRESTORABLE')


s = input()
t = input()
soln = ''
for i in range(len(s) - len(t) + 1):
	sol = True
	for j in range(len(t)):
		if not (s[i + j] == t[j] or s[i + j] == '?'):
			sol = False
			break
	if sol:
		soln = s[:i] + t + s[i + len(t):]
print(soln.replace('?', 'a') if soln != '' else 'UNRESTORABLE')


S = input()
T = input()
(ls, lt) = (len(S), len(T))
ans = 'UNRESTORABLE'
for i in range(ls - lt + 1):
	for j in range(lt):
		if S[i + j] not in (T[j], '?'):
			break
	else:
		ans = (S[:i] + T + S[i + lt:]).replace('?', 'a')
print(ans)


s = input()
t = input()
ns = len(s)
nt = len(t)
ans = 'UNRESTORABLE'
for i in range(ns - nt + 1):
	if all([s[i + j] == '?' or s[i + j] == t[j] for j in range(nt)]):
		ans = s[:i] + t + s[i + nt:]
		ans = ans.replace('?', 'a')
print(ans)


import sys
import math
import re
sys.setrecursionlimit(10 ** 8)
ini = lambda : int(sys.stdin.readline())
inm = lambda : map(int, sys.stdin.readline().split())
inl = lambda : list(inm())
ins = lambda : sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print('\x1b[33m', *a, '\x1b[0m', **dict(file=sys.stderr, **kw))
s2 = input()
t = input()
s2_r = s2[::-1]
t_r = t[::-1]
ans_flag = False
for i in range(len(s2)):
	for j in range(i + 1, len(s2) + 1):
		if j - i == len(t_r):
			flag = True
			for (k, l) in enumerate(range(i, j)):
				if s2_r[l] != t_r[k] and s2_r[l] != '?':
					flag = False
			if flag == True:
				ans = s2_r[:i] + t_r + s2_r[j:]
				ans = ans.replace('?', 'a')
				ans = ans[::-1]
				print(ans)
				ans_flag = True
				break
	else:
		continue
	break
if ans_flag == False:
	print('UNRESTORABLE')


import re
s = input()
t = input()
s = s.replace('?', '.')
n_s = len(s)
n_t = len(t)
res = []
for i in range(n_s - n_t + 1):
	m = re.match(s[i:i + n_t], t)
	if not m:
		continue
	res.append((s[:i] + t + s[i + n_t:]).replace('.', 'a'))
if not res:
	print('UNRESTORABLE')
else:
	print(min(res))


S = list(input())
T = input()
ans = 'UNRESTORABLE'
for i in range(len(S) - len(T) + 1):
	key = S[:]
	for (n, t) in enumerate(T):
		if key[i + n] not in ('?', t):
			break
		else:
			key[i + n] = t
		if n == len(T) - 1:
			ans = ''.join(key).replace('?', 'a')
print(ans)


S = input()
T = input()
l = len(T)
ind = 51
for i in range(len(S) - l + 1):
	flag = 0
	for j in range(l):
		if S[i + j] != '?' and S[i + j] != T[j]:
			flag = 1
	if flag == 0:
		ind = i
if ind == 51:
	print('UNRESTORABLE')
	exit()
print(S[:ind].replace('?', 'a') + T + S[ind + l:].replace('?', 'a'))


S_prime = input()
T = input()
start_ind = -1
for i in range(len(S_prime) - len(T) + 1):
	for (j, c) in enumerate(T):
		if S_prime[i + j] == c or S_prime[i + j] == '?':
			pass
		else:
			break
	else:
		start_ind = i
if start_ind == -1:
	print('UNRESTORABLE')
	return
S = S_prime[:start_ind] + T + S_prime[start_ind + len(T):]
print(S.replace('?', 'a'))


S = input()
T = input()
ls = len(S)
lt = len(T)
unrestorable = 'z' * 50
ans = unrestorable
for i in range(ls - lt + 1):
	for (j, t) in enumerate(T):
		s = S[i + j]
		if s != t and s != '?':
			break
	else:
		key = (S[:i] + T + S[i + lt:]).replace('?', 'a')
		ans = min(ans, key)
print(ans if ans != unrestorable else 'UNRESTORABLE')


s = input()
t = input()
match_index = 51
for i in range(len(s) - len(t) + 1):
	s_tmp = s[i:i + len(t)]
	for j in range(len(t)):
		if s_tmp[j] == t[j] or s_tmp[j] == '?':
			pass
		else:
			break
	else:
		match_index = i
if match_index == 51:
	print('UNRESTORABLE')
else:
	s_replace = ''
	for i in range(match_index):
		s_replace += s[i]
	s_replace += t
	for i in range(match_index + len(t), len(s)):
		s_replace += s[i]
	res = ''
	for i in s_replace:
		if i == '?':
			res += 'a'
		else:
			res += i
	print(res)


s = input()
t = input()
n = len(s)
m = len(t)
for i in range(n - m, -1, -1):
	x = s[i:i + m]
	for j in range(m + 1):
		if j == m:
			print((s[:i] + t + s[i + m:]).replace('?', 'a'))
			return
		if x[j] == '?':
			continue
		elif x[j] != t[j]:
			break
print('UNRESTORABLE')


S = input()
T = input()
l_s = len(S)
l_t = len(T)
ans = []
i = 0
while i + l_t <= l_s:
	j = 0
	while j < l_t:
		if S[i + j] == '?' or S[i + j] == T[j]:
			j += 1
		else:
			break
	if j == l_t:
		A = S[:i] + T + S[i + l_t:]
		A = A.replace('?', 'a')
		ans.append(A)
	i += 1
print(sorted(ans)[0] if ans else 'UNRESTORABLE')


S = input()
T = input()

def match(s, t):
	for (c, d) in zip(s, t):
		if c == '?':
			continue
		elif c == d:
			continue
		else:
			return False
	return True
for i in range(len(S) - len(T), -1, -1):
	s = S[i:i + len(T)]
	if match(s, T):
		print((S[:i] + T + S[i + len(T):]).replace('?', 'a'))
		return
print('UNRESTORABLE')


def main():
	with open(0) as f:
		(S, T) = f.read().split()
	for i in reversed(range(len(S) - len(T) + 1)):
		for j in reversed(range(len(T))):
			if S[i + j] == T[j] or S[i + j] == '?':
				continue
			else:
				break
		else:
			S = S[:i] + T + S[i + len(T):]
			S = S.replace('?', 'a')
			print(S)
			break
	else:
		print('UNRESTORABLE')
main()


S = input()
T = input()
X = sorted(((S[:i] + T + S[i + len(T):]).replace('?', 'a') for i in range(len(S) - len(T) + 1) if all((s == '?' or s == t for (s, t) in zip(S[i:i + len(T)], T)))))
print(X[0] if len(X) > 0 else 'UNRESTORABLE')


s = input()
t = input()
n = len(s)
m = len(t)
ind = -1
for i in range(n - m + 1):
	f = 0
	for j in range(m):
		c = s[n - i - 1 - j]
		if t[m - 1 - j] != c and c != '?':
			break
		else:
			f += 1
	if f == m:
		ind = i
		break
if ind == -1:
	print('UNRESTORABLE')
else:
	s = s[:n - ind - m] + t + s[n - ind:]
	s = s.replace('?', 'a')
	print(s)


nim = input()
mike = input()
for i in range(len(nim) - len(mike) + 1)[::-1]:
	for j in range(len(mike))[::-1]:
		if nim[i + j] != mike[j] and nim[i + j] != '?':
			break
	else:
		nim = nim[:i] + mike + nim[i + len(mike):]
		print(nim.replace('?', 'a'))
		exit()
print('UNRESTORABLE')


S = list(input())
T = list(input())
ls = len(S)
lt = len(T)
for i in range(ls - lt, -1, -1):
	isok = True
	for j in range(lt):
		if S[i + j] == '?':
			continue
		if S[i + j] != T[j]:
			isok = False
			break
	if isok:
		S[i:i + lt] = T
		ans = ''
		for s in S:
			if s == '?':
				ans += 'a'
			else:
				ans += s
		print(ans)
		return
print('UNRESTORABLE')


S = input()
T = input()
lt = len(T)
ls = len(S)
S += '%' * lt
if ls < lt:
	flg = 0
else:
	for i in range(ls - lt + 1, -1, -1):
		flg = 1
		for j in range(i, i + lt):
			s = S[j]
			if s == '?':
				continue
			if s == '%' or s != T[j - i]:
				flg = 0
				break
		if flg == 1:
			break
if flg:
	print((S[0:i] + T + S[i + lt:ls]).replace('?', 'a'))
else:
	print('UNRESTORABLE')


s = str(input())
t = str(input())
for i in range(len(s) - len(t) + 1):
	l = s[len(s) - len(t) - i:len(s) - i]
	if all([l[i] == t[i] or l[i] == '?' for i in range(len(t))]):
		s = s[:len(s) - len(t) - i] + t + s[len(s) - i:]
		break
s = s.replace('?', 'a')
if t in s:
	print(s)
else:
	print('UNRESTORABLE')


s = input()
t = input()
ans = []
for i in range(len(s) - len(t) + 1):
	for j in range(len(t)):
		if s[i + j] != t[j] and s[i + j] != '?':
			break
	else:
		a = ''
		for k in s[0:i] + t + s[i + len(t):]:
			if k == '?':
				a += 'a'
			else:
				a += k
		ans += [a]
ans = sorted(ans)
if ans:
	print(ans[0])
else:
	print('UNRESTORABLE')


SP = input()
T = input()
S = ''
for i in range(len(SP) - len(T), -1, -1):
	cnt = 0
	for j in range(len(T)):
		if SP[i + j] == T[j] or SP[i + j] == '?':
			cnt = cnt + 1
	if cnt == len(T):
		S = (SP[:i] + T + SP[i + len(T):]).replace('?', 'a')
		break
if S == '':
	print('UNRESTORABLE')
else:
	print(S)


import re
Sd = input()
T = input()
Sdr = Sd[::-1].replace('?', '.')
Tr = T[::-1]
for i in range(len(Sdr) - len(Tr) + 1):
	pattern = Sdr[i:i + len(Tr)]
	if re.match(pattern, Tr):
		print(Sdr.replace(pattern, Tr, 1).replace('.', 'a')[::-1])
		break
else:
	print('UNRESTORABLE')


S = input()
T = input()
len_S = len(S)
len_T = len(T)
for i in range(len_S - len_T, -1, -1):
	if not all((s in ['?', t] for (s, t) in zip(S[i:i + len_T], T))):
		continue
	print((S[:i] + T + S[i + len_T:]).replace('?', 'a'))
	exit()
print('UNRESTORABLE')


import sys
s = input()
t = input()
lenS = len(s)
lenT = len(t)
for i in range(lenS - lenT, -1, -1):
	sub = s[i:i + lenT]
	for j in range(lenT):
		if sub[j] != '?' and sub[j] != t[j]:
			break
	else:
		s = s.replace('?', 'a')
		print(s[:i] + t + s[i + lenT:])
		sys.exit()
	continue
print('UNRESTORABLE')


S = input()
T = input()
n = len(S)
m = len(T)
for i in range(n - m, -1, -1):
	x = S[i:i + m]
	for j in range(m + 1):
		if j == m:
			print((S[:i] + T + S[i + m:]).replace('?', 'a'))
			exit()
		if x[j] == '?':
			continue
		elif x[j] != T[j]:
			break
print('UNRESTORABLE')


import re
S = input()
T = input()
S = S.replace('?', '.')
t_len = len(T)
for i in reversed(range(len(S) - t_len + 1)):
	if re.match(S[i:i + t_len], T) is not None:
		S = S[:i] + T + S[i + t_len:]
		print(S.replace('.', 'a'))
		break
else:
	print('UNRESTORABLE')


s_o = str(input().strip())
t_o = str(input().strip())
dic = []
for i in range(len(s_o) - len(t_o) + 1):
	s = s_o
	t = t_o
	flg = 0
	for j in range(len(t_o)):
		if s[i + j] == t[j] or s[i + j] == '?':
			s = s[:i + j] + t[j] + s[i + j + 1:]
		else:
			flg = 1
			break
	if flg:
		continue
	s = s.replace('?', 'a')
	dic.append(s)
if len(dic) == 0:
	print('UNRESTORABLE')
else:
	dic.sort()
	print(dic[0])


(S, T) = [list(input()) for _ in range(2)]
k = -1
for i in range(len(S) - len(T) + 1):
	ok = True
	for j in range(len(T)):
		if S[i + j] != '?' and S[i + j] != T[j]:
			ok = False
			break
	if ok:
		k = i
if k == -1:
	print('UNRESTORABLE')
else:
	for i in range(len(T)):
		S[i + k] = T[i]
	print(''.join(S).replace('?', 'a'))


S = input()
T = input()
len_S = len(S)
len_T = len(T)
if len_S < len_T:
	print('UNRESTORABLE')
	quit()
candidates = tuple(((S[:i] + T + S[i + len_T:]).replace('?', 'a') for i in range(len_S - len_T + 1) if all((s in ('?', t) for (s, t) in zip(S[i:], T)))))
print(min(candidates) if candidates else 'UNRESTORABLE')


S = input()
T = input()
koho = []
for i in range(len(S) - len(T) + 1):
	for j in range(len(T)):
		if S[i + j] != '?' and S[i + j] != T[j]:
			break
	else:
		koho.append(S[:i] + T + S[i + len(T):])
result = sorted([s.replace('?', 'a') for s in koho])
print('UNRESTORABLE' if result == [] else result[0])


import re
s = input()
t = input()
regex = '([?' + '][?'.join(t[::-1]) + '])'
m = re.split(regex, s[::-1])
if len(m) == 1:
	print('UNRESTORABLE')
else:
	m[1] = t[::-1]
	print(''.join(m).replace('?', 'a')[::-1])


s = input()
t = input()
S = 'UNRESTORABLE'
for i in range(len(s) - len(t), -1, -1):
	flag = all([s[i + j] == t[j] or s[i + j] == '?' for j in range(len(t))])
	if flag:
		S = s[:i] + t + s[i + len(t):]
		S = S.replace('?', 'a')
		break
print(S)


s = list(input()[::-1])
t = list(input()[::-1])
for shift in range(len(s) - len(t) + 1):
	for i in range(len(t)):
		if s[i + shift] != '?' and s[i + shift] != t[i]:
			break
	else:
		s[shift:shift + len(t)] = t
		print(''.join(s[::-1]).replace('?', 'a'))
		break
else:
	print('UNRESTORABLE')


s = input()
t = input()
(n, m) = (len(s), len(t))
for i in range(n - m, -1, -1):
	match = True
	for j in range(m):
		if s[i + j] != '?' and s[i + j] != t[j]:
			match = False
			break
	if match:
		print(s[:i].replace('?', 'a') + t + s[i + m:].replace('?', 'a'))
		return
print('UNRESTORABLE')


Sp = str(input())
T = list(input())
ans = []
ANS = []
for i in range(len(Sp) - len(T) + 1):
	S = list(Sp)
	for j in range(len(T)):
		if S[i + j] == T[j] or S[i + j] == '?':
			S[i + j] = T[j]
			if j == len(T) - 1:
				ans.append(S)
		else:
			break
if len(ans) == 0:
	print('UNRESTORABLE')
else:
	for i in range(len(ans)):
		for j in range(len(Sp)):
			if ans[i][j] == '?':
				ans[i][j] = 'a'
		ANS.append(''.join(ans[i]))
	ANS.sort()
	print(ANS[0])


s = str(input())
t = str(input())
ss = []
for i in range(len(s) - len(t) + 1):
	for j in range(len(t)):
		if s[i + j] not in ('?', t[j]):
			break
	else:
		u = s[:i] + t + s[i + len(t):]
		ss.append(u.replace('?', 'a'))
if ss:
	print(min(ss))
else:
	print('UNRESTORABLE')


import re
Sd = input()
T = input()
Sdls = list(Sd)
Sdls.reverse()
Sdre = ''.join(Sdls)
Tls = list(T)
Tls.reverse()
Tre = ''.join(Tls)
st = -1
for i in range(0, len(Sd) - len(T) + 1):
	f = 1
	for j in range(len(T)):
		if Tre[j] == Sdre[i + j] or Sdre[i + j] == '?':
			continue
		else:
			f = 0
			break
	if f == 1:
		st = i
		break
if st == -1:
	print('UNRESTORABLE')
else:
	Sdrels = list(Sdre)
	for j in range(len(T)):
		Sdrels[j + st] = Tre[j]
	for j in range(len(Sd)):
		if Sdrels[j] == '?':
			Sdrels[j] = 'a'
	ans = ''.join(reversed(Sdrels))
	print(ans)


S_ = input()
T = input()
len_T = len(T)
len_S = len(S_)
A = []
for i in range(len_S - len_T + 1):
	flg = True
	for (t, s) in zip(T, S_[i:i + len_T]):
		if s != '?' and s != t:
			flg = False
	if flg == True:
		S = ''
		for j in range(len_S):
			if i <= j < i + len_T:
				S += T[j - i]
			elif S_[j] == '?':
				S += 'a'
			else:
				S += S_[j]
		A.append(S)
ans = 'z' * (len_S + 1)
for S in A:
	if S < ans:
		ans = S
if ans == 'z' * (len_S + 1):
	print('UNRESTORABLE')
else:
	print(ans)


Sd = input()
T = input()
indexes = []
for i in range(len(Sd)):
	if Sd[i] != '?':
		indexes.append(i)
t0 = 0
S_list = []
while t0 <= len(Sd) - len(T):
	flg = 0
	tmp_S = Sd[:t0] + T + Sd[t0 + len(T):]
	for index in indexes:
		if Sd[index] != tmp_S[index]:
			flg = 1
	if flg:
		t0 += 1
		continue
	tmp_S = tmp_S.replace('?', 'a')
	S_list.append(tmp_S)
	t0 += 1
if not S_list:
	print('UNRESTORABLE')
	return
S_list.sort()
print(S_list[0])


s = input()
t = input()
s_streak = 0
s_streak_ind = -1
for j in range(len(s) - 1, -1, -1):
	for i in range(j, -1, -1):
		if s_streak_ind == -1:
			if s[i] == '?' or s[i] == t[len(t) - 1 - s_streak]:
				if s_streak == len(t) - 1:
					s_streak_ind = i
					s_streak = 0
				else:
					s_streak += 1
			else:
				s_streak = 0
	s_streak = 0
if s_streak_ind == -1:
	print('UNRESTORABLE')
else:
	ansl = []
	for i in range(len(s)):
		if s[i] == '?':
			if s_streak_ind <= i < s_streak_ind + len(t):
				ansl.append(t[i - s_streak_ind])
			else:
				ansl.append('a')
		else:
			ansl.append(s[i])
	print(''.join(ansl))


import sys
s = input()
T = input()
for i in range(len(s) - len(T) + 1, 0, -1):
	for j in range(len(T)):
		if T[j] != s[i - 1 + j] and '?' != s[i - 1 + j]:
			break
	else:
		s = s[:i - 1] + T + s[i + len(T) - 1:]
		s = s.replace('?', 'a')
		print(s)
		sys.exit()
else:
	print('UNRESTORABLE')


sd = input()
t = input()
ls = len(sd)
lt = len(t)
ans = []
for i in range(ls - lt, -1, -1):
	for (j, k) in zip(sd[i:i + lt], t):
		if j != '?' and j != k:
			break
	else:
		temp = sd[:i] + t + sd[i + lt:]
		ans.append(temp.replace('?', 'a'))
if not ans:
	print('UNRESTORABLE')
else:
	ans.sort()
	print(ans[0])


from copy import deepcopy
s = list(input())
t = list(input())
ls = len(s)
lt = len(t)
rev_s = s[::-1]
rev_t = t[::-1]
for x in range(ls - lt + 1):
	if rev_s[x:x + lt] == ['?'] * lt:
		for y in range(lt):
			rev_s[x + y] = rev_t[y]
		ns = rev_s[::-1]
		S = ''.join(ns)
		ans = S.replace('?', 'a')
		print(ans)
		return
for i in range(lt):
	for j in range(i, ls):
		if rev_t[i] == rev_s[j]:
			flag = True
			t_temp = deepcopy(rev_t)
			s_temp = deepcopy(rev_s)
			for k in range(-i, lt - i):
				if j + k >= ls or j + k < 0:
					flag = False
					break
				elif t_temp[i + k] == s_temp[j + k]:
					pass
				elif s_temp[j + k] == '?':
					s_temp[j + k] = t_temp[i + k]
				elif t_temp[i + k] != s_temp[j + k]:
					flag = False
					break
			if flag:
				ns = s_temp[::-1]
				S = ''.join(ns)
				ans = S.replace('?', 'a')
				print(ans)
				return
print('UNRESTORABLE')


s = list(input())
t = list(input())
s.reverse()
t.reverse()
l = len(t)
ld = len(s) - len(t) + 1
for i in range(ld):
	cnt = 0
	for j in range(l):
		if s[j + i] == '?' or s[j + i] == t[j]:
			cnt += 1
	if cnt == l:
		ans = []
		for p in range(i):
			if s[p] == '?':
				ans.append('a')
			else:
				ans.append(s[p])
		for p in t:
			ans.append(p)
		for p in range(ld - i - 1):
			if s[l + p + i] == '?':
				ans.append('a')
			else:
				ans.append(s[l + i + p])
		ans.reverse()
		for p in ans:
			print(p, end='')
		break
else:
	print('UNRESTORABLE')


s = input()
t = input()
sl = len(s)
tl = len(t)
a = ''
ans = ['']
for i in range(sl - tl + 1):
	flg = 0
	for j in range(tl):
		if s[i + j] != '?' and s[i + j] != t[j]:
			flg = 1
	if flg == 0:
		a = s[:i] + t + s[tl + i:]
		a = a.replace('?', 'a')
		ans.append(a)
		a = ''
ans.sort()
if len(ans) == 1:
	print('UNRESTORABLE')
else:
	print(ans[1])


S = input()
T = input()
S = S[::-1]
T = T[::-1]
res = list()
for i in range(len(S) - len(T) + 1):
	flag = True
	for j in range(len(T)):
		if S[i + j] == '?' or S[i + j] == T[j]:
			continue
		else:
			flag = False
	if flag == True:
		ans = ''
		for k in range(len(S)):
			if i <= k <= i + len(T) - 1:
				ans += T[k - i]
			elif S[k] != '?':
				ans += S[k]
			else:
				ans += 'a'
		ans = ans[::-1]
		res.append(ans)
if res:
	res.sort()
	print(res[0])
else:
	print('UNRESTORABLE')


s = input()
t = input()
ans = 'UNRESTORABLE'
for i in range(len(s) - len(t) + 1):
	ok = True
	for j in range(len(t)):
		if s[i + j] != '?' and s[i + j] != t[j]:
			ok = False
	if ok:
		ans = s[:i] + t + s[i + len(t):]
		ans = ans.replace('?', 'a')
print(ans)


S_ = input()
T = input()
S = 'UNRESTORABLE'
for (i, s) in enumerate(S_):
	if i + len(T) > len(S_):
		break
	for j in range(len(T)):
		if S_[i + j] != T[j] and S_[i + j] != '?':
			break
	else:
		S = S_[:i] + T + S_[i + len(T):]
		S = S.replace('?', 'a')
print(S)


def main():
	s = input()
	t = input()
	ans = []
	for i in range(len(s) - len(t) + 1):
		for j in range(len(t)):
			if len(s) <= i + j or (s[i + j] != t[j] and s[i + j] != '?'):
				break
		else:
			ans.append((s[:i] + t + s[i + j + 1:]).replace('?', 'a'))
	ans.sort()
	print(ans[0] if len(ans) > 0 else 'UNRESTORABLE')

def __starting_point():
	main()
__starting_point()


s = list(input())
t = list(input())
num = len(t)
fail = 'UNRESTORABLE'
flag = False
ans = []
count_out = 0
for i in range(len(s)):
	start = i
	end = i + len(t)
	if end > len(s):
		break
	tar = s[start:end]
	index = 0
	name_flag = True
	for (a, b) in zip(tar, t):
		if a == b:
			pass
		elif a == '?':
			tar[index] = str(b)
		else:
			name_flag = False
			break
		index += 1
	if name_flag is False:
		ans.append(['z'] * len(s))
		count_out += 1
	else:
		pre_org = s[:start]
		post_org = s[end:]
		tar_mod = pre_org + tar + post_org
		ans.append(tar_mod)
if count_out == len(s) - len(t) + 1:
	print(fail)
else:
	ans_s = sorted(ans)
	aa = ans_s[0]
	a2 = ''.join(aa)
	a3 = a2.replace('?', 'a')
	print(a3)


S = input()
T = input()
ss = []
for i in range(0, len(S) - len(T) + 1):
	for j in range(len(T)):
		if S[i + j] not in ('?', T[j]):
			break
	else:
		s = S[:i] + T + S[i + len(T):]
		ss.append(s.replace('?', 'a'))
if ss:
	print(min(ss))
else:
	print('UNRESTORABLE')


s = input()
t = input()
n = len(s)
k = len(t)
for i in range(n - k, -1, -1):
	ok = True
	for j in range(k):
		if s[i + j] == '?' or s[i + j] == t[j]:
			continue
		else:
			ok = False
			break
	if ok:
		print(s[:i].replace('?', 'a') + t + s[i + k:].replace('?', 'a'))
		return
print('UNRESTORABLE')


import re
S = input()
Sa = S.replace('?', 'a')
Sd = S.replace('?', '.')
T = input()
word_L = []
for i in range(len(S) - len(T) + 1):
	if re.match(Sd[i:i + len(T)], T) is not None:
		s = Sa[:i] + T + Sa[i + len(T):]
		word_L.append(s)
ans = 'UNRESTORABLE'
if word_L:
	ans = sorted(word_L)[0]
print(ans)


s = list(input())
t = input()
k = []
for i in range(len(s) - len(t) + 1):
	m = i
	for j in t:
		if s[m] == j or s[m] == '?':
			m += 1
		else:
			break
	else:
		l = s[:i] + list(t) + s[i + len(t):]
		for i in l:
			if i == '?':
				l[l.index(i)] = 'a'
		k.append(''.join(l))
if len(k) == 0:
	k.append('UNRESTORABLE')
print(min(k))


S = input()
T = input()
lt = len(T)
ls = len(S)
if ls < lt:
	f = 0
else:
	for i in range(ls - lt, -1, -1):
		f = 1
		for (s, t) in zip(S[i:i + lt], T):
			if s == '?' or s == t:
				continue
			f = 0
		if f:
			break
print((S[0:i] + T + S[i + lt:ls]).replace('?', 'a') if f else 'UNRESTORABLE')


s = input()
t = input()
i = -1
for j in range(len(s) - len(t) + 1):
	if all((a == '?' or a == b for (a, b) in zip(s[j:], t))):
		i = j
if i == -1:
	print('UNRESTORABLE')
else:
	r = list(s)
	r[i:i + len(t)] = t
	for j in range(len(r)):
		if r[j] == '?':
			r[j] = 'a'
	print(''.join(r))


Sd = input()
T = input()
for i in range(len(Sd) - len(T) + 1):
	for j in range(len(T)):
		if Sd[len(Sd) - i - j - 1] not in (T[len(T) - j - 1], '?'):
			break
	else:
		print((Sd[:len(Sd) - i - len(T)] + T + Sd[len(Sd) - i:]).replace('?', 'a'))
		exit()
print('UNRESTORABLE')


S = input()
T = input()
L = []
for i in range(len(S) - len(T) + 1):
	for j in range(len(T)):
		if S[i + j] not in ('?', T[j]):
			break
	else:
		l = S[:i] + T + S[i + len(T):]
		l = l.replace('?', 'a')
		L.append(l)
if L:
	print(min(L))
else:
	print('UNRESTORABLE')


s = input()
t = input()
tn = len(t)
ans = []
for i in range(len(s) - tn + 1):
	for (j, k) in zip(s[i:tn + i], t):
		if j != k and j != '?':
			break
	else:
		ans.append(s[:i] + t + s[tn + i:])
ans.sort()
if ans:
	print(ans[0].replace('?', 'a'))
else:
	print('UNRESTORABLE')


s = list(input())
t = list(input())
lens = len(s)
lent = len(t)
for i in reversed(list(range(lens - lent + 1))):
	x = s[i:i + lent]
	ans = s
	flag = True
	for j in range(lent):
		if x[j] != t[j] and x[j] != '?':
			flag = False
			break
	if flag:
		ans = ['a' if a == '?' else a for a in ans[:i]] + t + ['a' if a == '?' else a for a in ans[i + lent:]]
		print(''.join(ans))
		return
print('UNRESTORABLE')


s = input()
t = input()
ls = len(s)
lt = len(t)
for i in range(ls, lt - 1, -1):
	a = s[i - lt:i]
	if all([a[j] == t[j] or a[j] == '?' for j in range(lt)]):
		s = s[:i - lt] + t + s[i:]
		print(s.replace('?', 'a'))
		exit()
print('UNRESTORABLE')


S2 = input()
T = input()
for i in reversed(range(0, len(S2) - len(T) + 1)):
	s = S2[i:i + len(T)]
	ok = True
	for j in range(len(T)):
		if not (s[j] == '?' or s[j] == T[j]):
			ok = False
	if ok:
		S = S2[:i] + T + S2[i + len(T):]
		S = S.replace('?', 'a')
		print(S)
		exit()
print('UNRESTORABLE')


S = input()
T = input()
flag = False
for i in range(len(S) - len(T), -1, -1):
	flag = True
	for j in range(len(T)):
		if S[i + j] != '?' and S[i + j] != T[j]:
			flag = False
			break
	if flag:
		break
if flag:
	U = S[:i] + T + S[i + len(T):]
	U = U.replace('?', 'a')
	print(U)
else:
	print('UNRESTORABLE')


S = input()
T = input()
from fnmatch import fnmatch
for i in range(len(S) - len(T), -1, -1):
	if fnmatch(T, S[i:i + len(T)]):
		r = S[:i] + T + S[i + len(T):]
		r = r.replace('?', 'a')
		print(r)
		break
else:
	print('UNRESTORABLE')


s = input()
t = input()
ns = len(s)
nt = len(t)
cand = []
for i in range(ns - nt + 1):
	j = 0
	temps = list(s)
	f1 = True
	while j <= nt - 1:
		if temps[i + j] == '?' or temps[i + j] == t[j]:
			temps[i + j] = t[j]
		else:
			f1 = False
			break
		j += 1
	if f1:
		temps = ''.join(temps)
		cand.append(temps.replace('?', 'a'))
if len(cand) == 0:
	ans = 'UNRESTORABLE'
else:
	cand.sort()
	ans = cand[0]
print(ans)


s = input()
t = input()
s_length = len(s)
t_length = len(t)
ans = ''
keep = ''
remind = 0
checker = False
for i in range(s_length):
	if i + t_length <= s_length:
		check = True
		for j in range(t_length):
			if (s[i + j] != t[j]) & (s[i + j] != '?'):
				check = False
		if check:
			checker = True
			ans = keep + t
			remind = i + t_length
	if s[i] == '?':
		keep += 'a'
	else:
		keep += s[i]
ans = ans + keep[remind:]
if checker:
	print(ans)
else:
	print('UNRESTORABLE')


S = input()
T = input()
n = len(S)
l = len(T)
for i in range(n - l + 1)[::-1]:
	cnt = 0
	for j in range(l):
		if S[i + j] == '?' or S[i + j] == T[j]:
			cnt += 1
	if cnt == l:
		S = list(S[:i] + T + S[i + l:])
		for k in range(n):
			if S[k] == '?':
				S[k] = 'a'
		print(''.join(S))
		break
else:
	print('UNRESTORABLE')


S = list(input())[::-1]
T = list(input())[::-1]
for i in range(len(S) - len(T) + 1):
	ans = S[:i]
	for j in range(len(T)):
		if S[i + j] != '?' and S[i + j] != T[j]:
			break
		else:
			ans.append(T[j])
	else:
		for j in range(i + len(T), len(S)):
			ans.append(S[j])
		print(''.join(map(str, ans[::-1])).replace('?', 'a'))
		break
else:
	print('UNRESTORABLE')


s = input()
t = input()
f = 0
e = len(t)
flg = 0
while e <= len(s):
	tmp = s[f:e]
	for i in range(len(t)):
		if tmp[i] != t[i] and tmp[i] != '?':
			break
		if i == len(t) - 1:
			ans = s[:f] + t + s[e:]
			flg = 1
	f += 1
	e += 1
if flg == 0:
	print('UNRESTORABLE')
else:
	print(ans.replace('?', 'a'))


s = input()
t = input()
for i in range(len(s) - len(t), -1, -1):
	s1 = s[i:i + len(t)]
	for (j, k) in enumerate(s1):
		if t[j] != k and k != '?':
			break
	else:
		s = s[:i] + t + s[i + len(t):]
		print(s.replace('?', 'a'))
		exit()
print('UNRESTORABLE')


(s, t) = (input(), input())
(ls, lt) = (len(s), len(t))
for i in range(ls - lt, -1, -1):
	for (j, s_) in enumerate(s[i:i + lt]):
		if (s_ == '?') | (s_ == t[j]):
			pass
		else:
			break
	else:
		s = s[:i] + t + s[i + lt:]
		s = s.replace('?', 'a')
		print(s)
		break
else:
	print('UNRESTORABLE')


S = list(input())[::-1]
T = list(input())[::-1]
for n in range(0, len(S) - len(T) + 1):
	for (i, t) in enumerate(T):
		if '?' == S[n + i]:
			continue
		if t != S[n + i]:
			break
	else:
		S[n:n + len(T)] = T
		print(''.join(S[::-1]).replace('?', 'a'))
		break
else:
	print('UNRESTORABLE')


import re
S = input().replace('?', '.')
T = input()
ans = []
moji = len(T)
for i in range(len(S) - len(T) + 1):
	m = re.search(S[i:moji + i], T)
	if m is not None:
		ans.append((S[0:i] + T + S[i + moji:]).replace('.', 'a'))
if ans:
	print(sorted(ans)[0])
else:
	print('UNRESTORABLE')


s = input()
t = input()
ans = list(s)
if len(s) >= len(t):
	for i in reversed(list(range(len(s) - len(t) + 1))):
		flg = True
		for j in range(len(t)):
			if s[i + j] == '?':
				continue
			if s[i + j] != t[j]:
				flg = False
				break
		if flg:
			for j in range(len(t)):
				ans[i + j] = t[j]
			break
else:
	flg = False
ans = ''.join(ans)
ans = ans.replace('?', 'a')
print(ans if flg else 'UNRESTORABLE')


s = input()
t = input()
ans = 'z' * len(s)
tmp = 'z' * len(s)
x = False
for i in range(len(s) - len(t) + 1):
	ok = True
	for j in range(len(t)):
		if not (s[i + j] == '?' or s[i + j] == t[j]):
			ok = False
	if ok:
		x = True
		tmp = s[:i] + t + s[i + len(t):]
		if ans > tmp:
			ans = tmp
if x:
	ans = ans.replace('?', 'a')
	print(ans)
else:
	print('UNRESTORABLE')


a = input()
b = input()
length = len(a) - len(b) + 1
ans = []
for i in range(length):
	A = list('?' * i + b + '?' * (length - i - 1))
	flag = True
	for j in range(len(a)):
		if a[j] == '?' or a[j] == A[j]:
			pass
		elif a[j] != '?' and A[j] == '?':
			A[j] = a[j]
		else:
			flag = False
	if flag:
		ans.append(''.join(A).replace('?', 'a'))
if ans:
	ans.sort()
	print(ans[0])
else:
	print('UNRESTORABLE')


S = input()
T = input()
for i in range(len(S) - len(T), -1, -1):
	flag = True
	for j in range(len(T)):
		if S[i + j] != '?' and S[i + j] != T[j]:
			flag = False
	if flag:
		S = S[:i] + T + S[i + len(T):]
		S = S.replace('?', 'a')
		print(S)
		exit()
print('UNRESTORABLE')


S = input()
T = input()
ans = ['UNRESTORABLE']
for i in range(len(S) - len(T) + 1):
	count = 0
	for j in range(len(T)):
		if S[i + j] == T[j] or S[i + j] == '?':
			count += 1
	if count == len(T):
		Sa = S[:i] + T + S[i + len(T):]
		pl = Sa.replace('?', 'a')
		ans.append(pl)
print(ans[-1])


Sd = input().strip()
T = input().strip()
S = ''
for i in range(len(Sd) - len(T), -1, -1):
	sub = Sd[i:i + len(T)]
	for (t, s) in zip(T, sub):
		if s != '?' and s != t:
			break
	else:
		S = Sd[:i] + T + Sd[i + len(T):]
		break
if S != '':
	print(S.replace('?', 'a'))
else:
	print('UNRESTORABLE')


s_ = input()
t = input()
filled_idx = [i for i in range(len(s_)) if s_[i] != '?']
for t_s in range(len(s_) - len(t), -1, -1):
	t_e = t_s + len(t)
	s = s_[:t_s] + t + s_[t_e:]
	if all((s[i] == s_[i] for i in filled_idx)):
		s = s.replace('?', 'a')
		print(s)
		break
else:
	print('UNRESTORABLE')


s = list(input())
t = list(input())
n = len(s)
m = len(t)
k = -1
for i in range(n - m + 1):
	x = s[i:i + m]
	flg = True
	for j in range(m):
		if x[j] != '?' and x[j] != t[j]:
			flg = False
			break
	if flg:
		k = i
if k != -1:
	for i in range(k, k + m):
		s[i] = t[i - k]
	for i in range(n):
		if s[i] == '?':
			s[i] = 'a'
	print(''.join(s))
else:
	print('UNRESTORABLE')


a = input()
b = input()
la = len(a)
lb = len(b)
ans = 'UNRESTORABLE'
for i in range(la - lb + 1):
	k = 1
	for j in range(lb):
		if a[i + j] == '?':
			continue
		if a[i + j] != b[j]:
			k = 0
	if k == 1:
		ans = i
if ans == 'UNRESTORABLE':
	print(ans)
else:
	ans = a[:ans] + b + a[ans + lb:]
	print(ans.replace('?', 'a'))


(s, t) = [input() for _ in range(2)]
(n, m) = map(len, [s, t])
for i in range(n - m, -1, -1):
	if not all((s_j in ['?', t_j] for (s_j, t_j) in zip(s[i:i + m], t))):
		continue
	print((s[:i] + t + s[i + m:]).replace('?', 'a'))
	exit()
print('UNRESTORABLE')


s = input()
t = input()
ans = ''
for i in range(len(s) - len(t), -1, -1):
	st = s[i:i + len(t)]
	cnt = 0
	for (si, ti) in zip(st, t):
		if si == '?' or si == ti:
			cnt += 1
	if cnt == len(t):
		ans = s[:i] + t + s[i + len(t):]
		ans = ans.replace('?', 'a')
		print(ans)
		return
else:
	print('UNRESTORABLE')


S = input()
T = input()
(s, t) = (len(S), len(T))
c = 'z' * s
for i in range(s - t + 1):
	if all((S[i + j] in (T[j], '?') for j in range(t))):
		c = min(c, S[:i] + T + S[i + t:])
print('UNRESTORABLE' if c == 'z' * s else c.replace('?', 'a'))


sd = input()
t = input()
lsd = len(sd)
lt = len(t)
for i in range(lsd - lt, -1, -1):
	for j in range(lt):
		if sd[i + j] != '?' and sd[i + j] != t[j]:
			break
	else:
		print((sd[:i] + t + sd[i + lt:]).replace('?', 'a'))
		break
else:
	print('UNRESTORABLE')


S = list(input())
T = list(input())
S.reverse()
T.reverse()
flag = False
for i in range(len(S) - len(T) + 1):
	k = 0
	for t in range(i, i + len(T)):
		if S[t] != '?' and S[t] != T[k]:
			break
		k += 1
		if k == len(T):
			flag = True
			w = i
	if flag:
		break
t = 0
if flag:
	for i in range(w, w + len(T)):
		S[i] = T[t]
		t += 1
	S.reverse()
	an = ''
	for i in range(len(S)):
		if S[i] == '?':
			an += 'a'
		else:
			an += S[i]
	print(an)
else:
	print('UNRESTORABLE')


s = input()
T = input()
s = ''.join([x if x != '?' else '1' for x in list(s)])
start = []
for i in range(len(s) - len(T) + 1):
	tmp = 0
	for j in range(len(T)):
		if s[i + j] == T[j] or s[i + j] == '1':
			tmp += 1
	if tmp == len(T):
		start.append(i)
candidates = []
t = len(T)
ans = ''
if len(start):
	for st in start:
		tmp = s[:st] + T + s[st + t:]
		candidates.append(tmp)
	candidates.sort()
	ans = candidates[0].replace('1', 'a')
else:
	ans = 'UNRESTORABLE'
print(ans)


ss = input()
t = input()
ls = len(ss)
lt = len(t)
before = []
after = []
for i in range(ls - lt + 1):
	for j in range(lt):
		if ss[i + j] != '?':
			if ss[i + j] != t[j]:
				break
	else:
		before += [ss[:i] + t + ss[i + lt:]]
for k in before:
	after += [k.replace('?', 'a')]
if after:
	after = sorted(after)
	print(after[0])
else:
	print('UNRESTORABLE')


def find(S, T):
	return all((s == t for (s, t) in zip(S, T) if s != '?'))
(S, T) = (input(), input())
L = []
for i in range(len(S) - len(T) + 1):
	if find(S[i:i + len(T)], T):
		L.append((S[:i] + T + S[i + len(T):]).replace('?', 'a'))
print(min(L) if len(L) else 'UNRESTORABLE')


(S, T) = (input(), input())
(s, t) = (len(S), len(T))
for i in range(s - t + 1):
	if all((c in '?' + d for (c, d) in zip(S[-i - t:], T))):
		S = S.replace('?', 'a')
		print(S[:-i - t] + T + S[s - i:])
		quit()
print('UNRESTORABLE')


S_ = list(input())
T = input()
n = len(S_)
m = len(T)
nonexist = 1
for i in range(n - 1, m - 2, -1):
	flg = True
	for j in range(m):
		if S_[i - j] != T[-j - 1] and S_[i - j] != '?':
			flg = False
			break
	if flg:
		nonexist = 0
		index = i
		break
if nonexist:
	print('UNRESTORABLE')
	return
index -= m - 1
for i in range(m):
	S_[index + i] = T[i]
for i in range(n):
	if S_[i] == '?':
		S_[i] = 'a'
print(''.join(S_))


from re import match
s = input().replace('?', '.')
t = input()
s_len = len(s)
t_len = len(t)
for i in range(s_len - t_len, -1, -1):
	if match(s[i:i + t_len], t):
		s = s.replace('.', 'a')
		print(s[:i] + t + s[i + t_len:])
		exit()
print('UNRESTORABLE')


s = input()
t = input()
ls = len(s)
lt = len(t)
check = False
ans = 'z' * 60
for i in range(ls - lt + 1):
	u = list(s)
	flag = True
	for j in range(lt):
		if u[i + j] == '?':
			u[i + j] = t[j]
		elif u[i + j] != t[j]:
			flag = False
			break
	if flag:
		check = True
		u = ''.join(u).replace('?', 'a')
		ans = sorted([ans, u])[0]
print(ans if check else 'UNRESTORABLE')


(s, t) = (input(), input())
n = len(s)
m = len(t)
ans = 'z' * (n + 1)
for i in range(n - m + 1):
	p = s[:i].replace('?', 'a')
	for j in range(m):
		if s[i + j] in ('?', t[j]):
			p += t[j]
		else:
			break
	else:
		p += s[len(p):].replace('?', 'a')
		ans = min(ans, p)
print('UNRESTORABLE' if len(ans) == n + 1 else ans)


s = input()
t: str = input()
n = len(s)
m = len(t)
for i in range(n - m, -1, -1):
	tlike = s[i:i + m]
	if tlike[0] == t[0] or tlike[0] == '?':
		for j in range(m + 1):
			if j == m:
				print((s[:i] + t + s[i + m:]).replace('?', 'a'))
				return
			if tlike[j] == '?':
				continue
			elif tlike[j] != t[j]:
				break
print('UNRESTORABLE')


(s, t) = (input(), input())
(l, m) = (len(s), len(t))
for i in range(l - m + 1):
	if all((c in '?' + d for (c, d) in zip(s[-i - m:], t))):
		s = s.replace(*'?a')
		exit(print(s[:-i - m] + t + s[l - i:]))
print('UNRESTORABLE')


S = input()
T = input()
(L, M) = (len(S), len(T))
a = -1
for i in range(L - M, -1, -1):
	if sum([1 for j in range(M) if S[i + j] == '?' or S[i + j] == T[j]]) == M:
		a = i
		break
print('UNRESTORABLE' if a < 0 else ''.join([T[i - a] if a <= i < a + M else 'a' if S[i] == '?' else S[i] for i in range(L)]))


S = input()
T = input()
same = lambda x, y: all((True if i == j or i == '?' else False for (i, j) in zip(x, y)))
n = len(T)
for i in range(len(S) - n, -1, -1):
	if same(S[i:i + n], T):
		S = S[:i] + T + S[i + n:]
		break
else:
	print('UNRESTORABLE')
	exit()
print(S.replace('?', 'a'))


s = input()
t = input()
s_l = len(s)
t_l = len(t)
ans = []
for i in range(s_l - t_l + 1):
	judge = True
	ts = list(s)
	for j in range(t_l):
		if ts[i + j] == t[j]:
			pass
		elif ts[i + j] == '?':
			ts[i + j] = t[j]
		else:
			judge = False
			break
		if judge and j == t_l - 1:
			for k in range(s_l):
				if ts[k] == '?':
					ts[k] = 'a'
			ans.append(ts)
if ans:
	ans.sort()
	print(''.join(ans[0]))
else:
	print('UNRESTORABLE')


import re
Sp = input().replace('?', '.')
T = input()
flag = 0
for i in range(len(Sp) - len(T), -1, -1):
	if re.match(Sp[i:i + len(T)], T):
		Sp = Sp[:i] + T + Sp[i + len(T):]
		flag = 1
		break
if flag == 1:
	print(Sp.replace('.', 'a'))
else:
	print('UNRESTORABLE')


import sys
S = ''.join(list(reversed(input())))
T = ''.join(list(reversed(input())))
for i in range(len(S) - len(T) + 1):
	for j in range(len(T)):
		if S[i + j] != '?' and T[j] != S[i + j]:
			break
	else:
		print(''.join(list(reversed((S[:i] + T + S[i + j + 1:]).replace('?', 'a')))))
		sys.exit()
print('UNRESTORABLE')


s = list(input())
t = list(input())
num = len(s) - len(t)
ans1 = -1
for i in range(num + 1):
	num1 = 0
	num2 = num - i
	for j in range(len(t)):
		if s[num2 + j] != t[j] and s[num2 + j] != '?':
			num1 = 1
			break
	if num1 == 0:
		ans1 = num2
		break
if ans1 == -1:
	print('UNRESTORABLE')
else:
	ans = ''
	for i in range(len(t)):
		s[ans1 + i] = t[i]
	for i in range(len(s)):
		if s[i] == '?':
			s[i] = 'a'
		ans += s[i]
	print(ans)


s = input()
t = input()
u = []
for i in range(len(s) - len(t) + 1):
	for j in range(len(t)):
		if s[i + j] != '?' and s[i + j] != t[j]:
			break
	else:
		u.append(s[:i].replace('?', 'a') + t + s[i + len(t):].replace('?', 'a'))
if len(u) == 0:
	print('UNRESTORABLE')
	exit()
u.sort()
print(u[0])


S = list(input())
T = list(input())
if len(S) < len(T):
	print('UNRESTORABLE')
else:
	S = S[::-1]
	T = T[::-1]
	for i in range(len(S) - len(T) + 1):
		if all((T[j] == S[i + j] or S[i + j] == '?' for j in range(len(T)))):
			S[i:i + len(T)] = T
			S = S[::-1]
			print(''.join(S).replace('?', 'a'))
			exit()
	print('UNRESTORABLE')


import re
(s, t) = (input().replace(*'?.'), input())
(l, m, *c) = (len(s), len(t))
for i in range(l - m + 1):
	if re.match(s[i:i + m], t):
		c += ((s[:i] + t + s[i + m:]).replace(*'.a'),)
print(c and min(c) or 'UNRESTORABLE')


S = input()
T = input()
N = len(S)
n = len(T)
ans = []
for i in range(N - n + 1):
	for j in range(n):
		if S[i + j] != T[j] and S[i + j] != '?':
			break
	else:
		s = []
		for j in range(i):
			if S[j] == '?':
				s.append('a')
			else:
				s.append(S[j])
		for j in range(i, i + n):
			s.append(T[j - i])
		for j in range(i + n, N):
			if S[j] == '?':
				s.append('a')
			else:
				s.append(S[j])
		ans.append(''.join(s))
if len(ans) == 0:
	print('UNRESTORABLE')
else:
	ans.sort()
	print(ans[0])


import re
S = input().replace('?', '.')
T = input()
ans = []
for i in range(len(S) - len(T), -1, -1):
	if re.match(S[i:i + len(T)], T):
		ans.append((S[:i] + T + S[i + len(T):]).replace('.', 'a'))
print(min(ans) if ans else 'UNRESTORABLE')


s = input()
t = input()
ls = len(s)
lt = len(t)
f = False
for i in range(ls - lt, -1, -1):
	f = True
	for j in range(lt):
		if not (s[i + j] == '?' or s[i + j] == t[j]):
			f = False
			break
	if f:
		ns = s[:i] + t + s[i + lt:]
		print(''.join(map(lambda x: 'a' if x == '?' else x, list(ns))))
		break
if not f:
	print('UNRESTORABLE')


S = input()
T = input()
for i in range(len(S) - len(T) + 1):
	target = S[len(S) - len(T) - i:len(S) - i]
	can_search = True
	for key in range(len(T)):
		if target[key] != '?':
			if target[key] != T[key]:
				can_search = False
				break
	if can_search:
		new_key = S[:len(S) - len(T) - i]
		new_key += T
		new_key += S[len(new_key):]
		print(new_key.replace('?', 'a'))
		return
print('UNRESTORABLE')


import sys
sys.setrecursionlimit(10 ** 6)
s = list(str(input()))
t = list(str(input()))
ans = []
for i in range(len(s) - len(t) + 1):
	ans_tmp = ''
	for j in range(len(s)):
		if j >= i and i + len(t) > j:
			if s[j] == '?' or s[j] == t[j - i]:
				ans_tmp += t[j - i]
			else:
				break
		elif s[j] == '?':
			ans_tmp += 'a'
		else:
			ans_tmp += s[j]
	if len(ans_tmp) != len(s):
		continue
	else:
		ans.append(ans_tmp)
ans.sort()
if len(ans) == 0:
	print('UNRESTORABLE')
else:
	print(ans[0])


s = input()
t = input()

def check(A, B):
	for (a, b) in zip(A, B):
		if a != '?' and a != b:
			return False
	return True
for i in range(len(s) - len(t) + 1)[::-1]:
	if check(s[i:i + len(t)], t):
		print((s[:i] + t + s[i + len(t):]).replace('?', 'a'))
		exit()
print('UNRESTORABLE')


_S = list(input())
T = list(input())
N = len(_S)
M = len(T)
candidates = []
for i in range(N - M + 1):
	if _S[i] == '?' or _S[i] == T[0]:
		S = _S.copy()
		flg = True
		for j in range(M):
			if S[i + j] == '?':
				S[i + j] = T[j]
			elif S[i + j] != T[j]:
				flg = False
				break
		if flg:
			for k in range(N):
				if S[k] == '?':
					S[k] = 'a'
			candidates.append(''.join(S))
if len(candidates) == 0:
	print('UNRESTORABLE')
else:
	print(min(candidates))


S0 = input()
T = input()
(n, m) = (len(S0), len(T))
if n < m:
	print('UNRESTORABLE')
	return
(start, end) = (-1, -1)
for i in reversed(range(n - m + 1)):
	ok = True
	for j in range(m):
		ok = ok and (S0[i + j] == T[j] or S0[i + j] == '?')
	if ok:
		start = i
		end = i + m - 1
		break
if start >= 0:
	S = ''
	for i in range(n):
		if start <= i <= end:
			S += T[i - start]
		elif S0[i] == '?':
			S += 'a'
		else:
			S += S0[i]
	print(S)
else:
	print('UNRESTORABLE')


S = input()
T = input()
l = len(S)
m = len(T)
for n in range(l - m + 1):
	if all((c in '?' + d for (c, d) in zip(S[-n - m:], T))):
		S = S.replace('?', 'a')
		print(S[:-n - m] + T + S[l - n:])
		exit()
print('UNRESTORABLE')


s = input()
t = input()
ans = 'UNRESTORABLE'
for i in range(len(s) - len(t) + 1):
	flag = True
	for j in range(len(t)):
		if s[i + j] == t[j] or s[i + j] == '?':
			continue
		else:
			flag = False
	if flag:
		ans = s[:i] + t + s[i + len(t):]
		ans = ans.replace('?', 'a')
print(ans)


s = input()[::-1]
t = input()[::-1]
res = 'UNRESTORABLE'
for i in range(len(s) - len(t) + 1):
	for (ss, tt) in zip(s[i:i + len(t)], t):
		if ss == '?' or ss == tt:
			continue
		break
	else:
		res = (s[:i] + t + s[i + len(t):])[::-1].replace('?', 'a')
		break
print(res)


s = input()
t = input()
sl = len(list(s))
tl = len(list(t))
for i in range(sl - tl + 1)[::-1]:
	c = 0
	for j in range(tl):
		if s[i + j] == t[j] or s[i + j] == '?':
			c += 1
		else:
			break
	if c == tl:
		print((s[:i] + t + s[i + tl:]).replace('?', 'a'))
		exit()
print('UNRESTORABLE')


s = input()
t = input()
ans = 'UNRESTORABLE'
for i in range(len(s) - len(t), -1, -1):
	valid = True
	for j in range(len(t)):
		if s[i + j] != '?' and s[i + j] != t[j]:
			break
	else:
		ans = (s[:i] + t + s[i + len(t):]).replace('?', 'a')
		break
print(ans)


import copy
S = list(input())
T = input()
lS = len(S)
lT = len(T)
ans = []
for s in range(lS - lT + 1):
	temp = copy.copy(S)
	for t in range(lT):
		if temp[s + t] != T[t] and temp[s + t] != '?':
			break
		else:
			temp[s + t] = T[t]
	else:
		temp = [temp[i] if temp[i] != '?' else 'a' for i in range(lS)]
		ans.append(''.join(temp))
ans = sorted(ans)
if len(ans) == 0:
	print('UNRESTORABLE')
else:
	print(ans[0])


a = input()
b = input()
c = len(a)
d = len(b)
for i in range(c - d + 1):
	e = a[c - d - i:c - i]
	for j in range(d + 1):
		if j == d:
			print((a[:c - d - i] + b + a[c - i:]).replace('?', 'a'))
			exit()
		if e[j] == '?':
			continue
		elif e[j] != b[j]:
			break
print('UNRESTORABLE')


S = input()
T = input()
ls = len(S)
lt = len(T)
ret = 'UNRESTORABLE'
for i in range(ls - lt + 1):
	judge = True
	for t in range(lt):
		if S[i + t] != T[t] and S[i + t] != '?':
			judge = False
			break
	if judge:
		ret = S[:i] + T + S[i + lt:]
ret = ret.replace('?', 'a')
print(ret)


S = input()
Sa = S.replace('?', 'a')
T = input()
nt = len(T)
ans = list()
for i in range(len(S) - nt + 1):
	X = S[i:i + nt]
	for (x, t) in zip(X, T):
		if x == '?':
			continue
		if x != t:
			break
	else:
		ans.append(Sa[:i] + T + Sa[i + nt:])
ans.sort()
print(ans[0] if ans else 'UNRESTORABLE')


s = input()
t = input()
found = False
st = 0
for i in range(len(s) - len(t) + 1):
	for j in range(len(t)):
		if s[i + j] != t[j] and s[i + j] != '?':
			break
	else:
		found = True
		st = i
if not found:
	print('UNRESTORABLE')
else:
	ans = s[:st] + t + s[st + len(t):]
	print(ans.replace('?', 'a'))


s = input()
t = input()
lst = []
for i in range(len(s) - len(t) + 1):
	ss = s[i:i + len(t)]
	f = True
	for (a, b) in zip(ss, t):
		if a != b and a != '?':
			f = False
			break
	if f:
		st = s[:i] + t + s[i + len(t):]
		lst.append(st.replace('?', 'a'))
if lst == []:
	print('UNRESTORABLE')
else:
	lst.sort()
	print(lst[0])


s = input()[::-1]
t = input()[::-1]

def match(string, substring):
	for (a, b) in zip(string, substring):
		if a == '?':
			continue
		if a != b:
			return False
	return True
LEN_S = len(s)
LEN_T = len(t)
ans = ''
for i in range(LEN_S - LEN_T + 1):
	sub = s[i:i + LEN_S]
	if match(sub, t):
		ans = s[:i] + t + s[i + LEN_T:]
		ans = ans[::-1].replace('?', 'a')
		break
else:
	print('UNRESTORABLE')
	return
print(ans)


S = input()
T = input()
if len(S) < len(T):
	print('UNRESTORABLE')
else:
	cand = []
	for i in range(len(S) - len(T) + 1):
		if all((s == '?' or s == t for (s, t) in zip(S[i:i + len(T)], T))):
			cand.append(S[:i].replace('?', 'a') + T + S[i + len(T):].replace('?', 'a'))
	print('UNRESTORABLE' if len(cand) == 0 else min(cand))


(s, y) = (input() for i in range(2))
ans = '{' * len(s)
pa = ans
for i in range(len(s) - len(y) + 1):
	for j in range(len(y)):
		if s[i + j] != '?' and s[i + j] != y[j]:
			break
	else:
		ans = min(ans, s[:i].replace('?', 'a') + y + s[i + len(y):].replace('?', 'a'))
if pa == ans:
	print('UNRESTORABLE')
else:
	print(ans)


import sys

def accept_input():
	S = input()
	T = input()
	return (S, T)
(S, T) = accept_input()
fromhere = -1
for i in range(len(S) - len(T) + 1):
	for j in range(len(T)):
		if S[i + j] == '?':
			continue
		elif S[i + j] == T[j]:
			continue
		elif S[i + j] != T[j]:
			break
	else:
		fromhere = i
if fromhere == -1:
	print('UNRESTORABLE')
	return
sd = ''
for i in range(len(S)):
	if i < fromhere:
		if S[i] == '?':
			sd += 'a'
		else:
			sd += S[i]
	elif i >= fromhere + len(T):
		if S[i] == '?':
			sd += 'a'
		else:
			sd += S[i]
	else:
		sd += T[i - fromhere]
print(sd)


S = str(input())
T = str(input())
ans = []
for i in range(len(S) - len(T) + 1):
	for j in range(len(T)):
		if S[i + j] not in ('?', T[j]):
			break
	else:
		U = S[:i] + T + S[i + len(T):]
		ans.append(U.replace('?', 'a'))
print(min(ans) if ans else 'UNRESTORABLE')


S = input()
T = input()
ans = 'UNRESTORABLE'
for j in range(len(S) - len(T) + 1):
	flag = 1
	for i in range(len(T)):
		if S[j + i] == T[i] or S[j + i] == '?':
			continue
		else:
			flag = 0
	if flag:
		ans = S[0:j] + T + S[j + len(T):]
		ans = ans.replace('?', 'a')
print(ans)


import sys
import re
import queue
import collections
import math
from decimal import *
from copy import deepcopy
from collections import Counter, deque
import heapq
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from typing import Callable
from decimal import Decimal, getcontext

def i_input():
	return int(input())

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

def i_list():
	return list(i_map())

def i_row(N):
	return [i_input() for _ in range(N)]

def i_row_list(N):
	return [i_list() for _ in range(N)]

def s_input():
	return input()

def s_map():
	return input().split()

def s_list():
	return list(s_map())

def s_row(N):
	return [s_input for _ in range(N)]

def s_row_str(N):
	return [s_list() for _ in range(N)]

def s_row_list(N):
	return [list(s_input()) for _ in range(N)]

def lcm(a, b):
	return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
	S_dush = s_input()
	T = s_input()
	answer_list = []
	for i in range(0, len(S_dush) - len(T) + 1):
		flag = True
		count = 0
		for j in range(0, len(T)):
			if S_dush[i + j] != '?' and S_dush[i + j] != T[j]:
				count = j
				flag = False
		if flag:
			tmp = ''
			for j in range(0, len(S_dush)):
				if S_dush[j] == '?':
					tmp = tmp + 'a'
				else:
					tmp = tmp + S_dush[j]
			tmp = tmp[0:i] + T + tmp[i + len(T):len(S_dush)]
			answer_list.append(tmp)
	if len(answer_list) == 0:
		print('UNRESTORABLE')
	else:
		answer_list.sort()
		print(answer_list[0])

def __starting_point():
	main()
__starting_point()


(s, t) = (input(), input())
ans = 'z' * len(s)
for i in range(len(s) - len(t) + 1):
	pre = s[:i].replace('?', 'a')
	for (x, y) in zip(list(s[i:]), list(t)):
		if x != '?' and x != y:
			break
		pre += y
	else:
		pre += s[i + len(t):].replace('?', 'a')
		ans = min(ans, pre)
print(ans if ans != 'z' * len(s) else 'UNRESTORABLE')


S = input()
T = input()
M = -1
for i in range(len(S) - len(T) + 1):
	t = True
	for j in range(len(T)):
		t *= S[i + j] == T[j] or S[i + j] == '?'
	if t:
		M = i
if M == -1:
	print('UNRESTORABLE')
	exit()
print((S[:M] + T + S[M + len(T):]).replace('?', 'a'))


s = list(input())
ls = len(s)
t = list(input())
lt = len(t)
can = []
for i in range(ls - lt, -1, -1):
	ok = 0
	for j in range(lt):
		if s[i + j] == t[j] or s[i + j] == '?':
			ok += 1
	if ok == lt:
		c = [0] * ls
		for k in range(ls):
			if s[k] == '?':
				if k < i or k >= i + lt:
					c[k] = 'a'
				else:
					c[k] = t[k - i]
			else:
				c[k] = s[k]
		can.append(''.join(c))
if len(can) == 0:
	print('UNRESTORABLE')
else:
	print(sorted(list(can))[0])


import re
S_ = input()
T = input()
Tr = T[::-1]
Sr = S_[::-1]
reg = ''.join(map(lambda x: '[{}?]'.format(x), Tr))
ans = re.sub(reg, Tr, Sr, count=1)
if ans.count(Tr) == 1:
	print(ans.replace('?', 'a')[::-1])
else:
	print('UNRESTORABLE')


S = list(input())
T = list(input())

def match(s, t):
	for (_s, _t) in zip(s, t):
		if not (_s == _t or _s == '?'):
			return False
	return True

def convert(S):
	for i in range(len(S)):
		if S[i] == '?':
			S[i] = 'a'
	return S

def replace(S, T, off):
	for i in range(len(T)):
		S[off + i] = T[i]
	return S
pos = -1
for i in reversed(range(0, len(S) - len(T) + 1)):
	if match(S[i:], T):
		pos = i
		break
if 0 <= pos:
	ans = S
	ans = replace(ans, T, pos)
	ans = convert(ans)
	print(*ans, sep='')
else:
	print('UNRESTORABLE')


def restore():
	for i in range(N - M, -1, -1):
		if all((s == '?' or s == t for (s, t) in zip(S[i:i + M], T))):
			ans = S[:i] + T + S[i + M:]
			return ''.join(('a' if c == '?' else c for c in ans))
	return 'UNRESTORABLE'
S = input()
T = input()
N = len(S)
M = len(T)
print(restore())


S = input()
T = input()
anslist = []
for i in range(len(S) - len(T) + 1):
	kouho = [0] * len(S)
	ok = 1
	for j in range(len(T)):
		if S[i + j] == T[j] or S[i + j] == '?':
			kouho[i + j] = T[j]
		else:
			ok = 0
			break
	if ok == 1:
		for k in range(len(S)):
			if kouho[k] == 0:
				if S[k] != '?':
					kouho[k] = S[k]
				else:
					kouho[k] = 'a'
		kouho = ''.join(kouho)
		anslist.append(kouho)
if len(anslist) == 0:
	ans = 'UNRESTORABLE'
else:
	anslist.sort()
	ans = anslist[0]
print(ans)


S = input()[::-1]
T = input()[::-1]
for k in range(1 + len(S) - len(T)):
	f = len(T)
	for j in range(len(T)):
		if S[k + j] == T[j] or S[k + j] == '?':
			f -= 1
	if f == 0:
		print((S[:k] + T + S[k + len(T):]).replace('?', 'a')[::-1])
		exit(0)
print('UNRESTORABLE')


import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque, Counter
from decimal import Decimal
import functools

def v():
	return input()

def k():
	return int(input())

def S():
	return input().split()

def I():
	return list(map(int, input().split()))

def X():
	return list(input())

def L():
	return list(input().split())

def l():
	return list(map(int, input().split()))

def lcm(a, b):
	return a * b // math.gcd(a, b)
sys.setrecursionlimit(10 ** 6)
mod = 10 ** 9 + 7
cnt = 0
ans = 0
inf = float('inf')
al = 'abcdefghijklmnopqrstuvwxyz'
AL = al.upper()
S = v()
T = v()
len_s = len(S)
len_t = len(T)
check = False
ans = []
if len_s < len_t:
	print('UNRESTORABLE')
	return
for i in range(len_s):
	if S[i] == '?':
		cnt += 1
		if cnt >= len_t:
			aaa = S.replace('?', 'a')
			ans.append(aaa[:i - len_t + 1] + T + aaa[i + 1:])
	elif S[i] in T:
		cnt = 0
		place = T.index(S[i])
		if len_s < len_t + i - place:
			break
		for j in range(i - place, len_t + i - place):
			if T[j - (i - place)] == S[j] or S[j] == '?':
				check = True
			else:
				check = False
				break
		if check:
			aaa = S.replace('?', 'a')
			ans.append(aaa[:i - place] + T + aaa[len_t + i - place:])
	else:
		cnt = 0
if len(ans) > 0:
	ans.sort()
	print(ans[0])
else:
	print('UNRESTORABLE')


from re import *
(s, t) = open(0)
t = t[:-1]
u = ''.join(('(%s|\\?)' % t for t in t))
a = []
j = len(t)
for i in range(len(s) - j):
	if match(u, s[i:i + j]):
		a.append(sub('\\?', 'a', s[:i]) + t + sub('\\?', 'a', s[i + j:]))
print(min(a or ['UNRESTORABLE']))


sd = input()
t = input()
found = False
for i in range(len(sd) - len(t), -1, -1):
	for j in range(len(t)):
		if sd[i + j] != '?' and sd[i + j] != t[j]:
			break
	else:
		ans = sd[:i] + t + sd[i + len(t):]
		ans = ans.replace('?', 'a')
		break
else:
	ans = 'UNRESTORABLE'
print(ans)


S = input()
T = input()
l = len(S)
k = len(T)
f = 0
if k > l:
	f = 0
else:
	for i in reversed(list(range(0, l - k + 1))):
		for j in range(k):
			if S[i + j] != T[j] and S[i + j] != '?':
				break
			if j == k - 1:
				f = 1
				s = i
		if f == 1:
			break
if f == 0:
	print('UNRESTORABLE')
else:
	S = S[:s] + T + S[s + k:]
	for i in range(l):
		if S[i] == '?':
			S = S[:i] + 'a' + S[i + 1:]
	print(S)


import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

def I():
	return int(input())

def F():
	return float(input())

def SS():
	return input()

def LI():
	return [int(x) for x in input().split()]

def LI_():
	return [int(x) - 1 for x in input().split()]

def LF():
	return [float(x) for x in input().split()]

def LSS():
	return input().split()

def resolve():
	S_ = SS()
	T = SS()
	len_S = len(S_)
	len_T = len(T)
	idx = -1
	for i in range(len_S - len_T, -1, -1):
		exists = True
		for j in range(len_T):
			if S_[i + j] != '?' and S_[i + j] != T[j]:
				exists = False
				break
		if exists:
			idx = i
			break
	if idx == -1:
		print('UNRESTORABLE')
	else:
		ans = list(S_)
		for i in range(len_S):
			if S_[i] == '?':
				if idx <= i < idx + len_T:
					ans[i] = T[i - idx]
				else:
					ans[i] = 'a'
		print(''.join(ans))

def __starting_point():
	resolve()
__starting_point()


import re
(S, T) = open(0)
S = S.replace('?', '.')
T = T[:-1]
s = len(S)
t = len(T)
for i in range(s - t, -1, -1):
	if re.match(S[i:i + t], T):
		print((S[:i] + T + S[i + t:]).replace('.', 'a'))
		exit()
print('UNRESTORABLE')


s = input()
t = input()
for i in range(len(s) - len(t) + 1)[::-1]:
	cnt = 0
	q = 0
	for j in range(len(t))[::-1]:
		if s[i + j] == '?':
			q += 1
		elif s[i + j] == t[j]:
			cnt += 1
	if cnt == len(t) - q:
		idx = i
		s = s[:idx] + t + s[idx + len(t):]
		for k in range(len(s)):
			if s[k] == '?':
				s = s[:k] + 'a' + s[k + 1:]
		print(s)
		break
else:
	print('UNRESTORABLE')


import re
_S = input().replace('?', '_')[::-1]
T = input()[::-1]
pattern = ''
for c in T:
	pattern += '[_' + c + ']'
match = re.search(pattern, _S)
if not match:
	print('UNRESTORABLE')
else:
	S = _S[:match.start()] + T + _S[match.end():]
	S = S.replace('_', 'a')
	print(S[::-1])