Harryxun/stf_run huggingface dataset:
# coding: utf-8
# Your code here!

s=input()
t=input()

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

### FIXED CODE ###

# coding: utf-8
# Your code here!

s=input()
t=input()
b=[]

if len(s)-len(t)<0:
    flg=False
else:
    for i in range(len(s)-len(t)+1):
        ans=s
        for j in range(len(t)):
            flg=True
            if s[i+j]=='?' or s[i+j]==t[j]:
                #print(ans)
                ans=ans[:i+j]+t[j]+('' if i+j+1>len(s) else ans[i+j+1:])
            else:
                flg=False
                break
        if flg==True:
            b.append(ans.replace('?','a'))
#print(b)
b.sort()

print(b[0] if len(b)>0 else 'UNRESTORABLE')
S = input()
s = [i for i in input()]
if s.count('R') == 3:
    print(3)
elif s.count('R') == 1:
    print(1)
elif s.count('R') == 0:
    print(0)
else:
    if S == 'RSR':
        print(1)
    else:
        print(2)

### FIXED CODE ###

S = input()
s = [i for i in S]
if s.count('R') == 3:
    print(3)
elif s.count('R') == 1:
    print(1)
elif s.count('R') == 0:
    print(0)
else:
    if S == 'RSR':
        print(1)
    else:
        print(2)
N = int(input())
M = int(input())

n = N-1
m = M-1

Even = N*n
Odd = M*m

print((Even+Odd)/2)

### FIXED CODE ###

N, M = map(int,input().split())

print(N*(N-1)//2+M*(M-1)//2)
x = int(input())
if x == 1:
    print(1)
else:
    n = 1
    for i in range(1,32):
        for j in range(2,10):
            m = i**j
            if m <= x and m > n:
                n = m
print(n)

### FIXED CODE ###

x = int(input())
if x == 1:
    print(x)
else:
    n = 1
    for i in range(1,32):
        for j in range(2,10):
            m = i**j
            if m <= x and m > n:
                n = m
    print(n)
s=input()

if(s=="ABC")print("ARC")
else if("ARC")print("ABC")




### FIXED CODE ###

s=input()

if(s=="ABC"):print("ARC")
if(s=="ARC"):print("ABC")
import collections
N=int(input())
d=list(map(int,input().split()))
dd = collections.Counten=int(input())
d=list(map(int,input().split()))
mod=998244353
from collections import Counter
q=Counter(d)
if q[0]!=1 or d[0]!=0:
	print(0)
	exit()
ans=1
for i in range(1,max(q)+1):
    ans *=pow(q[i-1],q[i],mod)
    ans %=mod
print(ans)

### FIXED CODE ###

n=int(input())
d=list(map(int,input().split()))
mod=998244353
from collections import Counter
q=Counter(d)
if q[0]!=1 or d[0]!=0:
	print(0)
	exit()
ans=1
for i in range(1,max(q)+1):
    ans *=pow(q[i-1],q[i],mod)
    ans %=mod
print(ans)
N ,K = map(int,inpuit())
if N%K == 0:
  print(0)
else:
  print(1)


### FIXED CODE ###

N ,K = map(int,input().split())
if N%K == 0:
  print(0)
else:
  print(1)
S=input()
T=input()
j=0
i=-1
flag = False
while i>=-1*len(S)-1+len(T):
    while j>=-1*len(T)-1:
        if i==-1*len(S)-1+len(T):
            A="UNRESTORABLE"
            flag=True
            break
        elif j==-1*len(T):
            if i!=-1:
                P=S.replace(S[i-len(T)+1:i+1],T,1)
                A=P.replace("?","a")
                i=-1*len(S)-1+len(T)
                flag=True
                break
            else:
                P=S.replace(S[i-len(T)+1:],T,1)
                A=P.replace("?","a")
                flag=True
                break
        elif S[i+j]==T[j-1] or S[i+j]=="?":
            j=j-1
        else:
            j=0
            i=i-1
    if flag:
        break
print(A)

### FIXED CODE ###

S1=input()
T1=input()
S=""
T=""
A=""
for i in range(1,len(S1)+1):
    S+=S1[-i]
for i in range(1,len(T1)+1):
    T+=T1[-i]
j=0
i=0
flag = False
while i<=len(S)+1-len(T):
    while j<=len(T)+1:
        if i==len(S)-len(T)+1:
            A="UNRESTORABLE"
            flag=True
            break
        elif j==len(T):
            P=S.replace(S[i:i+len(T)],T,1)
            Q=P.replace("?","a")
            for i in range(1,len(Q)+1):
                A+=Q[-i]
            flag=True
            break
        elif S[i+j]==T[j] or S[i+j]=="?":
            j+=1
        else:
            j=0
            i+=1
    if flag:
        break
print(A)
import math
a, b = map(int, input().split())
def pi(a):
    s= 0
    a+=1
    n = int(math.log2(a))
    b_q=1
    q = 2
    ans =0
    ans += (t//2)%2

    for i in range(1,n+1):
        b_q = q

        q*=2
        t = a%(q)
        ans += b_q*(max(0,t-b_q)%2)
    return ans
print((pi(b)^pi(a))^a)

### FIXED CODE ###

import math
o, b = map(int, input().split())
def pi(a):
    s= 0
    a+=1
    p = math.log2(a)
    p = int(p)
    qq=1
    q = 2
    ans =0
    t = 0
    t = a//2
    ans += t%2

    for i in range(1,p+1):
        qq = q

        q*=2
        t = a%(q)
        ans += qq*(max(0,t-qq)%2)
    return ans
print((pi(b)^pi(o))^o)
#B - Five Dishes(ABC123)
B=[]
C=[]
for i in range(5):
    S=int(input())
    if S%10==0:
        C.append(S)
    else:
        C.append(S+(10-S%10))
    if S%10!=0:
        B.append(S%10)
print(sum(C)-(10-min(B)))

### FIXED CODE ###

# B - Five Dishes(ABC123)
B=[]
C=[]
for i in range(5):
    S=int(input())
    if S%10==0:
        C.append(S)
    else:
        C.append(S+(10-S%10))
    if S%10!=0:
        B.append(S%10)
if B==[]:
    print(sum(C))
else:
    print(sum(C)-(10-min(B)))
import sys
# from math import sqrt, gcd, ceil, log
from bisect import bisect
from collections import defaultdict, Counter
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

# sys.setrecursionlimit(10**6)

# def func(arr, b):
# 	return([i-b for i in arr])

# def f(i, j, t):
# 	if t >=k:
# 		return(i+j)
# 	return(max(f(i+1, j, t+a_[i+1]), f(i, j+1, t+b_[j+1])))



def solve():
	a, b, k = read(); a_ = read(); b_ = read()
	dic = {}
	def f(i, j, t):
		# print(i, j, t, "******")
		key = (i, j, t)
		if key in dic:
			return(dic[key])
		if t == k:
			# print(i, j, t, "11111")
			return(i+j)
		if t > k:
			# print(i, j, t, "22222")
			return(i+j-1)
		if i ==a and j ==b:
			# print(i, j, t, "0"*5)
			return(i+j)
		if i == a:
			return(f(i, j+1, t + b_[j]))
		if j == b:
			return(f(i+1, j, t + a_[i]))
		

		x = f(i+1, j, t+a_[i]) if i < a else 0#f(i+1, j, t)
		y = f(i, j+1, t+b_[j]) if j < b else 0#f(i, j+1, t)
		dic[key] = max(x, y)
		return(dic[key])
	# for i in range(1, a): a_[i] += a_[i-1]
	# for i in range(1, b): b_[i] += b_[i-1]
	# ans = 0
	# while k > 0:
	# 	inda = bisect(a_, k); indb = bisect(b_, k)
	# 	# print(k, inda, indb, a_[inda-1], b_[indb-1])
	# 	if inda > indb:
	# 		k -= a_[inda-1];
	# 		ans += inda
	# 		a_ = func(a_[inda:], a_[inda-1])
	# 	elif inda == indb:
	# 		if a_[inda-1] < b_[indb-1]:
	# 			k -= a_[inda-1];
	# 			ans += inda
	# 			a_ = func(a_[inda:], a_[inda-1])
	# 		else:
	# 			k -= b_[indb-1];
	# 			ans += indb
	# 			b_ = func(b_[indb:], b_[indb-1])
	# 	else:
	# 		k -= b_[indb-1];
	# 		ans += indb
	# 		b_ = func(b_[indb:], b_[indb-1])
	ans = f(0, 0, 0)
	print(ans)





		

if __name__ == "__main__":
	solve()

### FIXED CODE ###

import sys
# from math import sqrt, gcd, ceil, log
from bisect import bisect
from collections import defaultdict, Counter
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

# sys.setrecursionlimit(10**6)



def solve():
	n, m, k = read()
	arr1 = [0]+read(); arr2 = [0]+read()
	for i in range(1, n+1):arr1[i] += arr1[i-1]
	for i in range(1, m+1):arr2[i] += arr2[i-1]

	i = 0; ans = 0
	while i < n+1 and arr1[i] <= k:
		tem = i + bisect(arr2, k-arr1[i])-1
		# print(tem, i, arr1[i], bisect(arr2, k-arr1[i]))
		ans = max(ans, tem)
		i += 1
	print(ans)

	





		

if __name__ == "__main__":
	solve()
n, k = map(int, input().split())
a = [int(i) for i in input().split()]
b = [-1] * (n+1)
now = 1
history = []

while b[now] == -1:
  b[now] = len(history)
  history.append(now)
  now = a[now-1]  

if now == 1:
    print(history[k % len(history)])
else:
    print(history[(k - now) % (len(history) - now) + now])

### FIXED CODE ###

n, k = map(int, input().split())
a = [int(i) for i in input().split()]
b = [-1] * (n+1)
now = 1
history = []

while b[now] == -1:
  b[now] = len(history)
  history.append(now)
  now = a[now-1]

c = len(history) - b[now]
l = b[now]

if k < l:
  print(history[k])
else:
  k -= l
  k %= c
  print(history[l+k])
n = int(input())
l = [int(input()) for _ in range(n)]
print(sum(l)-max(l)/2)

### FIXED CODE ###

d=int(input())
if d==25:
  print("Christmas")
elif d==24:
  print("Christmas Eve")
elif d==23:
  print("Christmas Eve Eve")
else:
  print("Christmas Eve Eve Eve")
N, M = map(int, input().split())

cities = {}
output = []
for i in range(M):
    x, y = map(int, input().split())
    cities[i+1] = [x,y]
    output.append(y)

ID = {}
county_old = 0
sorted_counties_years = sorted(cities.values())
for county,year in sorted_counties_years:
    if county_old == 0:
        county_old = county
        count = 1
        ID[year] = f'{county:06}{count:06}'
        count += 1
        continue
    elif county_old == county:
        ID[year] = f'{county:06}{count:06}'
        count += 1
    else:
        county_old = county
        count = 1
        ID[year] = f'{county:06}{count:06}'
        count += 1
for i in output:
    print(ID[i])

    


### FIXED CODE ###

N, M = map(int, input().split())

cities = {}
output = []
for i in range(M):
    x, y = map(int, input().split())
    cities[i+1] = [x,y]
    output.append(y)

ID = {}
county_old = 0
sorted_counties_years = sorted(cities.values())
for county,year in sorted_counties_years:
    if county_old == 0:
        county_old = county
        count = 1
        ID[year] = '{:06}{:06}'.format(county, count)
        count += 1
        continue
    elif county_old == county:
        ID[year] = '{:06}{:06}'.format(county, count)
        count += 1
    else:
        county_old = county
        count = 1
        ID[year] = '{:06}{:06}'.format(county, count)
        count += 1
for i in output:
    print(ID[i])
import numpy as np

n = int(input())
a = list(map(int, input().split()))
a = np.array(a)

# def gcd(a,b):
#     if(b==0):
#         return a
    
#     r = a%b
#     while(r!=0):
#         a = b
#         b = r
#         r = a%b
    
#     return b
    

# def lcm(a,b):
#     return a * b / gcd(a, b)

l = 1
# for i in range(len(a)):
#     if(l>a[i]):
#         l = lcm(l,a[i])
#     else:
#         l = lcm(a[i],l)

l = np.lcm.reduce(a)

count = 0
for i in range(len(a)):
    count += int(l/a[i])
    count = count % (1000000007)
print(count)

### FIXED CODE ###

from fractions import gcd
 
n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
l = 1
for i in a:
    l = i * l // (gcd(i, l))
 
cnt = 0
for i in a:
    cnt += l // i
print(cnt % mod)
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys
def main(N, K, A):
    lo = -1
    hi = 10**9
    while hi - lo > 1:
        m = (lo + hi) // 2
        if sum((a + m - 1) // m - 1 for a in A) <= K: hi = m
        else: lo = m
    print(hi)

if __name__ == '__main__':
    input = sys.stdin.readline
    N, K = map(int, input().split())
    * A, = map(int, input().split())
    main(N, K, A)


### FIXED CODE ###

# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys
from math import ceil
def main(N, K, A):
    A.sort(reverse=True)

    def f(x):
        res = 0
        for a in A:
            if a > x:
                res += a // x
            else:
                break
        return res

    lo = 0
    hi = 10**9
    for _ in range(100):
        m = (lo + hi) / 2
        if f(m) > K: lo = m
        else: hi = m
    print(ceil(lo))

if __name__ == '__main__':
    input = sys.stdin.readline
    N, K = map(int, input().split())
    *A, = map(int, input().split())
    main(N, K, A)
def resolve():
	S, T = input().split()
	if T[:-1] == S:
		print('Yes')
	else:
		print('No')
resolve()

### FIXED CODE ###

S = input()
T = input()
if T[:-1] == S:
	print('Yes')
else:
	print('No')
A,B=map(int,input().split())

def judge(a,b):
  if a > b:
    return "Alice"
  elif a = b:
    return "Draw"
  else:
    return "Bob"
  
print(judge(A,B))

### FIXED CODE ###

A,B=map(int,input().split())

def judge(a,b):
  if a > b > 1 or (a == 1 and b != 1):
    return "Alice"
  elif a == b:
    return "Draw"
  else:
    return "Bob"
  
print(judge(A,B))
def solve(S):
    if S in ["dream","dreamer","erase","eraser"]:
        return True
    elif len(S) <= 7:
        return False
    if S[0:7] == "dreamer":
        return solve(S[7:]) or solve(S[5:])
    elif S[0:5] == "dream":
        return solve(S[5:])
    if S[0:6] == "eraser":
        return solve(S[6:]) or solve(S[5:])
    elif S[0:5] == "erase":
        return solve(S[5:])

    return False

print("YES" if solve(input()) else "NO")

### FIXED CODE ###

s = input()[::-1]
flag = 1
i = 0
while i < len(s):
    if s[i:i+5] == "maerd" or s[i:i+5] == "esare":
        i += 5
    elif s[i:i+6] == "resare":
        i += 6
    elif s[i:i+7] == "remaerd":
        i += 7
    else:
        flag = 0
        break

print("YES" if flag else "NO")
s_input = input()
s = list(s_input)
s_reverse = list((reversed(s_input)))

count = 0
for i in range(int(len(s)/2)):
    if s[i] != s_reverse[i]int(x)
        count += 1

print(count)

### FIXED CODE ###

s_input = input()                                                                   
s = list(s_input)                                                                   
s_reverse = list((reversed(s_input)))                                               
                                                                                    
count = 0                                                                           
for i in range(int(len(s)/2)):                                                      
    if s[i] != s_reverse[i]:                                                        
        count += 1                                                                  
                                                                                    
print(count)
kotae = input()
print(kotae * kotae * kotae)

### FIXED CODE ###

input_lines = int(input())
print(input_lines **3)
s = string(input())

if (s=="Sunny"):
    print("Cloudy")
else if	(s=="Cloudy"):
    print("Rainy")
else:
    print("Sunny")

### FIXED CODE ###

s = str(raw_input())

if s=="Sunny":
    print ("Cloudy")
if s=="Cloudy":
    print ("Rainy")
if s=="Rainy":
    print ("Sunny")
a=int(input("input a"))
b=int(input("input b"))
print(a*b,2*(a+b))



### FIXED CODE ###

a,b=map(int,input().split())
x=a*b
y=2*(a+b)
print(x,y)
a,b= int(input().split())
if a > 9 or b > 9:
  print(-1)
else:
  print(str(a*b))

### FIXED CODE ###

a,b= map(int,input().split())
if a > 9 or b > 9:
  print(-1)
else:
  print(str(a*b))
a, b = map(int, input().split())
c = (a*b)%2
if c == 0:
	print("Even")
else
	print("Odd")


### FIXED CODE ###

a, b = map(int, input().split())
c = (a*b)%2
if c == 0:
	print("Even")
else:
	print("Odd")
n,m = map(int, input().split())
p = list(map(int,input().split()))
d = [list() for _ in range(n+1)]
cnt = 0
for _ in range(m):
  x,y = map(int, input().split())
  d[x].append(y)
  d[y].append(x)
gr = [0]*(n+1)
gr[0] = -1
gn = 0
for x in range(1,n+1):
  if gr[x] == 0:
    gn += 1
    gr[x] = gn
    l = [x]
    while l:
      cur = l.pop()
      for i in d[cur]:
        if i not in l and gr[i] == 0:
          gr[i] = gn
          l.append(i)
for i in range(n):
  if gr[i+1] == gr[p[i]]:
    cnt += 1
print(cnt)

### FIXED CODE ###

s = input()
k = int(input())
sub = set()
for i in range(len(s)):
  for j in range(1,k+1):
    sub.add(s[i:i+j])
print(sorted(list(sub))[k-1])
string = input()
result = string.count("R")
if(result == 2 and string[1] = "S"):
  print("1")
else:
  print(result)
  

### FIXED CODE ###

string = input()
result = string.count("R")
if(result == 2 and string[1] == "S"):
  print("1")
else:
  print(result)
n,a,b = map(int,input().split())
l = []

l.append(min(a,b))

if n >= a + b:
    l.append(0)
else:
    l.append(a + b - n)

print(''.join(l))


### FIXED CODE ###

n,a,b = map(int,input().split())
l = []

l.append(min(a,b))

if n >= a + b:
    l.append(0)
else:
    l.append(a + b - n)

print(l[0],l[1])
from heapq import*
R=range;I=lambda:map(int,input().split());n=int(input());g=[[]for _ in R(n+1)];z=[-1]*n;d=[1e9]*n+[0];q=[-1]*(n+1);r=;Q=[];heappush(Q,(0,-2,n))
for _ in R(n-1):a,b=I();a-=1;b-=1;g[a]+=[(1,a,b)];g[b]+=[(1,b,a)]
for _ in R(*I()):a,b=I();a-=1;g[n]+=[(b,n,a)];z[a]=b
while Q:
	e=heappop(Q)
	if q[e[2]]!=-1:continue
	q[e[2]]=e[1]
	for f in g[e[2]]:
		if d[f[2]]>e[0]+f[0]:d[f[2]]=e[0]+f[0];heappush(Q,(e[0]+f[0],f[1],f[2]))
for _ in g:
	if any(n!=e[1]and abs(d[e[1]]-d[e[2]])!=1 for e in _):r="No"
if any(~z[i]and z[i]!=d[i]for i in R(n)):r="No"
print(r or"Yes\n"+"\n".join(map(str,d[:n])))

### FIXED CODE ###

#!/usr/bin/python
def shortestPath(g,s,dist,prev):
	n = len(g)-1
	Q=[]
	heapq.heappush(Q,(0,-2,s))
	while Q:
		e = heapq.heappop(Q)
		if prev[e[2]]!=-1: continue
		prev[e[2]] = e[1]
		for f in g[e[2]]:
			if dist[f[2]] > e[0] + f[0]:
				dist[f[2]] = e[0] + f[0]
				heapq.heappush(Q,(e[0]+f[0],f[1],f[2]))

import sys,heapq
#if sys.version_info[0]>=3:raw_input=input

n=int(raw_input())
g=[[] for _ in range(n+1)]
for _ in xrange(n-1):
	a,b=map(int,raw_input().split())
	g[a-1]+=[(1,a-1,b-1)]
	g[b-1]+=[(1,b-1,a-1)]
z=[-1]*n
for _ in xrange(int(raw_input())):
	a,b=map(int,raw_input().split())
	g[n]+=[(b,n,a-1)]
	z[a-1]=b
a=[1e9]*n+[0]
shortestPath(g,n,a,[-1]*(n+1))
for i in xrange(n):
	if z[i]>=0 and z[i]!=a[i]:
		print('No')
		sys.exit()
for _ in g:
	for e in _:
		if e[1]<e[2] and abs(a[e[1]]-a[e[2]])!=1:
			print('No')
			sys.exit()
print('Yes')
print("\n".join(map(str,a[:n])))
def main():
    import math
    n,k = map(int,input().split())
    a = list(map(int,input().split()))
    def f(a,l):
        ans = 0
        for i in range(len(a)):
            ans += math.ceil(a[i]/l)-1
        return ans
    l,r = 1,max(a)
    while (r+l)//2!=r and (r+l)//2!=l:
        if f(a,(l+r)//2)>k:
            l = (l+r)//2
        elif f(a,(l+r)//2)<k:
            r = (l+r)//2
        else:
            break
    while True:
        if f(a,r)<=k:
            r -= 1
        else:
            print(r+1)
            return

if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    import math
    n,k = map(int,input().split())
    a = list(map(int,input().split()))
    def f(a,l):
        ans = 0
        for i in range(len(a)):
            ans += math.ceil(a[i]/l)-1
        return ans
    l,r = 1,max(a)
    while r-l>1:
        mid = (l+r)//2
        g = f(a,mid)
        if g>k:
            l = mid+1
        else:
            r = mid
    if f(a,l)<=k:
        print(l)
    else:
        print(r)

if __name__ == "__main__":
    main()
def attack(AB,H,N):
    AB.sort(key = lambda x:x[1])
    count = 0
    while H > 0:
        if AB[N-1][1] >= H:
            count += 1
            H = 0
            N -= 1
        elif len(AB) >= 2:
            if AB[N-1][0] >= AB[N-2][1]:
                num = (H-AB[N-1][1])//AB[N-1][0]
                H -= num*AB[N-1][0]
                count += num
                if H > AB[N-1][1]:
                    H -= AB[N-1][0]
                    count += 1
            else:
                count += 1
                H -= AB[N-1][1]
                N -= 1
        else:
            num = (H-AB[N-1][1])//AB[N-1][0]
            H -= num*AB[N-1][0]
            count += num
            if H > AB[N-1][1]:
                H -= AB[N-1][0]
                count += 1

    return count

def main():
    N,H = map(int,input().split())
    AB = [list(map(int,input().split())) for _ in range(N)]

    print(attack(AB,H,N))

if __name__ == "__main__":
    main()


### FIXED CODE ###

from math import ceil

def attack(ab,N,H):
    cut_max = 0
    for i in range(N):
        cut_max = max(cut_max,ab[i][0])

    throw = [ab[i][1] for i in range(N)]
    throw.sort(reverse = True)
    throw.append(0)

    cnt,pt = 0,0
    while H > 0:
        if throw[pt] > cut_max:
            H -= throw[pt]
            cnt += 1
            pt += 1
        else:
            cnt += (ceil(H/cut_max))
            H = 0

    return cnt

def main():
    N,H = map(int,input().split())
    ab = [list(map(int,input().split())) for _ in range(N)]

    print(attack(ab,N,H))

if __name__ == "__main__":
    main()
A = int(input())
B = int(input())
C = int(input())
X = int(input())
memo = np.zeros(3).reshape(1,3)

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if X == 500*i + 100*j + 50*k :
                result = np.array([i,j,k])
                memo = np.vstack([memo,result])

print(len(memo[1:]))

### FIXED CODE ###

import numpy as np
A = int(input())
B = int(input())
C = int(input())
X = int(input())
memo = np.zeros(3).reshape(1,3)

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if X == 500*i + 100*j + 50*k :
                result = np.array([i,j,k])
                memo = np.vstack([memo,result])

print(len(memo[1:]))
A= int(input().split())
if A[0] % 3 == 0 or A[1] % 3 == 0 or (A[0] + A[1]) % 3 == 0:
    print("Possible")
else:
    print("Impossible")

### FIXED CODE ###

A= (input().split())
if int(A[0]) % 3 == 0 or int(A[1]) % 3 == 0 or (int(A[0]) + int(A[1])) % 3 == 0:
    print("Possible")
else:
    print("Impossible")
# -*- coding: utf-8 -*-
n = input()
l = []
tail = 0
for i in xrange(n):
    cmd = raw_input().split()
    if cmd[0] == "insert":
        l.append(cmd[1])
    elif cmd[0] == "delete":
        l.pop(len(l) - l[::-1].index(cmd[1]) -1)
    elif cmd[0] == "deleteFirst":
        l.pop()
    elif cmd[0] == "deleteLast":
        tail += 1

print " ".join(l[tail:][::-1])

### FIXED CODE ###

# -*- coding: utf-8 -*-
n = input()
l = []
tail = 0
for i in xrange(n):
    cmd = raw_input().split()
    if cmd[0] == "insert":
        l.append(cmd[1])
    elif cmd[0] == "delete":
        try:
            l.pop(len(l) - l[::-1].index(cmd[1]) -1)
        except ValueError:
            pass
    elif cmd[0] == "deleteFirst":
        l.pop()
    elif cmd[0] == "deleteLast":
        tail += 1

print " ".join(l[tail:][::-1])
s,t,u = map(str,input().spilt())

print(str.upper(s[0]+str.upper(t[0]+str.upper(u[0]))



### FIXED CODE ###

s,t,u = input().split()

print(s[0].upper()+t[0].upper()+u[0].upper())
import sys

def main():
    # input = sys.stdin.readline

    _, _, m = input().split()
    m = int(m)
    alist = input().split()
    blist = input().split()

    waribiki = [input().split() for _ in range(m)]
    
    res = [None] * (len(alist)*len(blist) + m)
    count = 0
    for a in alist:
      for b in blist:
        res[count] = int(a)+int(b)
        count += 1

    for i in range(m):
        res[count] = int(alist[int(waribiki[i][0])-1]) + int(blist[int(waribiki[i][1])-1]) - int(waribiki[i][2])
        count += 1
      
    print(min(res))


if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys

def main():
    input = sys.stdin.readline

    a, b, m = input().split()
    a, b, m = int(a), int(b), int(m)
    alist = list(map(int, input().split()))
    blist = list(map(int, input().split()))

    waribiki = [input().split() for _ in range(m)]
    
    res = [200000] * (m + 1)
    count = 0

    for i in range(m):
        res[count] = alist[int(waribiki[i][0])-1] + blist[int(waribiki[i][1])-1] - int(waribiki[i][2])
        count += 1

    res[count] = min(alist) + min(blist)
      
    print(min(res))


if __name__ == '__main__':
    main()
lst = list(map(int,input().split()))
lst_2 = []
for i in range(len(lst)):
    lstt = lst
    x = lstt[i]
    del lstt[i]
    num = int(x) + int("".join(lstt))
    lst_2.append(num)
print(int(max(lst_2)))

### FIXED CODE ###

import itertools
lst = list(map(str,input().split()))
lst1 = list(itertools.permutations(lst))

ans_array = []
for i in range(len(lst1)):
    num1 = int(lst1[i][0]+lst1[i][1]) + int(lst1[i][2])
    num2 = int(lst1[i][0]) + int(lst1[i][1]+lst1[i][2])
    ans_array.append(num1)
    ans_array.append(num2)
print(max(ans_array))