Harryxun/stf_run huggingface dataset:
S = input()
T = input()
res = ''

for i in range(len(S) - len(T) + 1):
    for j in range(len(T)):
        start = i
        end = i + j
        if S[i+j] == T[j]:
            flag = 1
        elif S[i+j] == '?':
            flag = 0
        else:
            flag = -1
            break
    if flag == 1:
        break
            
if start == 0 and end == 0 and flag == -1:
    print('UNRESTORABLE')
    
else:
    j = 0
    for i in range(len(S)):
        if start <= i <= end:
            res += T[j]
            j += 1

        elif S[i] == '?':
            res += 'a'

        else:
            res += S[i]

    print(res)

### FIXED CODE ###

S = input()
T = input()


    
if True:
    tmp = -1
    for i in range(len(S) - len(T) + 1):
        start = -1
        for j in range(len(T)):
            if S[i+j] == T[j] or S[i+j] == '?':
                start = i
            else:
                start = -1
                break
                
        
        if start != -1:
                tmp = i
    if tmp == -1:
        print('UNRESTORABLE')
    else:
        res = ''
        count = 0
        for i in range(len(S)):
            if tmp <= i < tmp + len(T):
                res += T[count]
                count += 1
            elif S[i] == '?':
                res += 'a'
            else:
                res += S[i]

        print(res)
#問題D
import warnings
warnings.filterwarnings('ignore')
import pandas as pd
import numpy as np

N, W = list(map(int, input().split()))
w = np.array([0] * (N+1))
v = np.array([0] * (N+1))
for i in range(N):
    w[i+1], v[i+1] = map(int, input().split())

dp = np.array([[0] * (W+1)] * (N+1))
for i in range(1, N+1):
    for j in range(0, (W+1)):
        if j - w[i] >= 0:
            dp[i, j] = max(dp[i-1, j], dp[i-1, j-w[i]]+v[i])
        else:
            dp[i, j] = dp[i-1, j]

print(dp[N, W])



### FIXED CODE ###

#問題D
#これだとタイムアウト
import numpy as np
import warnings
warnings.filterwarnings('ignore')

N, W = list(map(int, input().split()))
w = np.array([0] * (N+1))
v = np.array([0] * (N+1))
for i in range(N):
    w[i+1], v[i+1] = map(int, input().split())

dp = np.array([[0] * (W+1)] * (N+1))
for i in range(1, N+1):
    tmp_arr = np.zeros(W + 1, dtype=int)
    tmp_arr = np.zeros(W + 1, dtype=int)
    tmp_arr[w[i]:] = dp[i-1][:-w[i]] + v[i]
    dp[i] = np.maximum(dp[i-1], tmp_arr)

print(dp[N, W])
N = int(input())
A = list(map(int, input().split()))
A.sort()

def divisor(x, m):
    ret = []
    for i in range(1, int(x**0.5)+1):
        if i >= m:
            return ret
            
        if x % i == 0:
            ret.append(i)
            compl = x//i
            if i*i != x and compl < m:
                ret.append(compl)
    return ret

divisor_dict = {}
m = 10 ** 10
for i in range(len(A)):
    if i==3:
        m = 0
        for key, val in divisor_dict:
            if val >= 2 and key > m:
                m = key
    
    div = divisor(A[i], m)
    for j in div:
        if j in divisor_dict:
            divisor_dict[j] += 1
        else:
            divisor_dict[j] = 1
        
max_val = 0
for key, val in divisor_dict.items():
    if val >= N-1 and key > max_val:
        max_val = key

print(max_val)


### FIXED CODE ###

N = int(input())
A = [0] + list(map(int, input().split()))

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

    return b

L = [0] * (N+1)
R = [0] * (N+2)

for i in range(1, N+1):
    ind = N+1-i
    L[i] = gcd(L[i-1], A[i-1])
    R[ind] = gcd(R[ind+1], A[ind])

ret = []
for i in range(1, N+1):
    ret.append(gcd(L[i], R[i+1]))

print(max(ret))
import sys
sys.setrecursionlimit(200000)
def f(i,ans,l,t):
  if (i+1) == (len(l)-1):
    if (ans+l[i]) > l[i+1]:
      ans = ans + l[i]-l[i+1]
      return t+ans
    else:
      return t
  else:
    if (ans+l[i]) > l[i+1]:
      ans = ans + l[i]-l[i+1]
      return f(i+1,ans,l,t+ans)
    else:
      return f(i+1,0,l,t)
n = input("")
an = input("").split(" ")
ani = [int(a) for a in an]
if len(ani) == 1:
  print("0")
else:
  print(str(f(0,0,ani,0)))

### FIXED CODE ###

import sys
sys.setrecursionlimit(2000000)
def f(i,ans,l,t):
  if (i+1) == (len(l)-1):
    if (ans+l[i]) > l[i+1]:
      ans = ans + l[i]-l[i+1]
      return t+ans
    else:
      return t
  else:
    if (ans+l[i]) > l[i+1]:
      ans = ans + l[i]-l[i+1]
      return f(i+1,ans,l,t+ans)
    else:
      return f(i+1,0,l,t)
n = input("")
an = input("").split(" ")
ani = [int(a) for a in an]
if len(ani) == 1:
  print("0")
else:
  print(str(f(0,0,ani,0)))
import math

r=int(import())

print(r*math.pi*2)

### FIXED CODE ###

import math

r=float(input())

print(2*r*math.pi)
r1,c1,r2,c2=map(int, input().split())
MOD=10**9+7

M=10**6
fac=[0]*(M+1)
ifac=[0]*(M+1)
fac[0]=1
for i in range(1,M+1):
    fac[i]=fac[i-1]*i%MOD
ifac[M]=pow(fac[M],MOD-2,MOD)
for i in range(M-1,0,-1):
    ifac[i]=ifac[i+1]*(i+1)%MOD

def comb(a,b): return fac[a]*ifac[a-b]*ifac[b]%MOD

def g(r,c): return comb(r+c+2,r+1)-1

ans=g(r2,c2)-g(r1-1,c2)-g(r2,c1-1)+g(r1-1,c1-1)
print(ans%MOD)

### FIXED CODE ###

r1,c1,r2,c2=map(int, input().split())
MOD=10**9+7

M=2*(10**6+1)
fac=[0]*(M+1)
ifac=[0]*(M+1)
fac[0]=1
for i in range(1,M+1):
    fac[i]=fac[i-1]*i%MOD
ifac[M]=pow(fac[M],MOD-2,MOD)
for i in range(M-1,0,-1):
    ifac[i]=ifac[i+1]*(i+1)%MOD

def comb(a,b): return fac[a]*ifac[a-b]*ifac[b]%MOD

def g(r,c): return comb(r+c+2,r+1)-1

ans=g(r2,c2)-g(r1-1,c2)-g(r2,c1-1)+g(r1-1,c1-1)
print(ans%MOD)
p = input()
q = input()
r = input()

s = int(p)
t = int(q)
u = int(r)

total_time = s + t + u

times = [s, t, u]
max_time = max(times)

min_time = total_time - max_time

print(min_time)

### FIXED CODE ###

P, Q, R = map(int, input().split())
 
X = max([P, Q, R])
 
print(P + Q + R - X)
import sys
from functools import lru_cache
sys.setrecursionlimit(100000)

@lru_cache(maxsize = None)

def dp(n):
	if n == 0:
		return 0
	if n == 1:
		return abs(l[0] - l[1])
	return min(dp(n - 1) + abs(l[n] - l[n - 1]), dp(n - 2) + abs(l[n] - l[n - 2]))

n = int(input())
l = [int(i) for i in input().split(" ")]

print(dp(n - 1)) 

### FIXED CODE ###

n = int(input())
l = [int(i) for i in input().split(" ")]
dp = [0 for i in range(n + 1)]
dp[1] = abs(l[0] - l[1])
for i in range(2, n):
	dp[i] = min(dp[i - 1] + abs(l[i] - l[i - 1]), dp[i - 2] + abs(l[i] - l[i - 2]))
print(dp[n - 1])
N = int(input())
nums = [int(i) for i in input().split()]
nums = sorted(list((set(nums))), reverse=True)
def compute_divs(n):
    divs = []
    if n == 1: return 1
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            divs.append(i)
            if i != n // i:
                divs.append(n//i)
    divs.append(n)
    return divs

if len(nums) == 1: ans = nums[0]
else:
    divs1 = compute_divs(nums[0])
    divs2 = compute_divs(nums[1])
    divs = sorted(list(set(divs1+divs2)))
    for i in reversed(divs):
        c= 0
        for j in range(len(nums)):
            if nums[j] % i != 0:
                c += 1
                if c == 2:
                    break
        if c <= 1:
            ans = i
            break
print(ans)

### FIXED CODE ###

N = int(input())
nums = [int(i) for i in input().split()]
nums_sorted = sorted(list((set(nums))), reverse=True)
def compute_divs(n):
    divs = []
    if n == 1: return [1]
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            divs.append(i)
            if i != n // i:
                divs.append(n//i)
    divs.append(n)
    return divs
ans = 1
if len(nums_sorted) == 1: ans = nums[0]
else:
    divs1 = compute_divs(nums_sorted[0])
    divs2 = compute_divs(nums_sorted[1])
    divs = sorted(list(set(divs1+divs2)))
    for i in reversed(divs):
        c= 0
        for j in nums:
            if j % i != 0:
                c += 1
                if c == 2:
                    break
        if c <= 1:
            ans = i
            break
print(ans)
K,N=map(int,input().split())
A=list(map(int,input().split()))
l=[]
p = A[-1]-K
for a in A:
  l.append(a-l)
  p=a
print(sum(l)-max(l))

### FIXED CODE ###

K,N=map(int,input().split())
A=list(map(int,input().split()))
l=[]
p = A[-1]-K
for a in A:
  l.append(a-p)
  p=a
print(sum(l)-max(l))
import numpy as np

n, m, k = map(int, input().split())
a = np.array([0] + list(map(int, input().split())))
b = np.array([0] + list(map(int, input().split())))

for i in range(n):
    a[i+1] += a[i]

for i in range(m):
    b[i+1] += b[i]

ans = 0

for i in range(n+1):
    if k < a[i]:
        continue
    l = 0
    r = m + 1
    while r - l > 1:
        mid = (l + r) // 2
        if b[mid] + a[i] <= k:
            l = mid
        else:
            r = mid

    ans = max(ans, i + l)

print(ans)


### FIXED CODE ###

import numpy as np

n, m, k = map(int, input().split())
a = np.array([0] + list(map(int, input().split())))
b = np.array([0] + list(map(int, input().split())))

for i in range(n):
    a[i+1] += a[i]

for i in range(m):
    b[i+1] += b[i]

ans = 0
r = m

for i in range(n+1):
    while 0 < r and k < a[i] + b[r]:
        r -= 1

    if a[i] + b[r] <= k:
        ans = max(ans, i + r)

print(ans)
N = int(input())
l = []

for i in range(1,N-1):
    tmp1 = list(str(i))
    tmp2 = list(str(N-i))
    s1 = 0
    s2 = 0
    for j in range(len(tmp1)):
        s1 += int(tmp1[j])
    for j in range(len(tmp2)):
        s2 += int(tmp2[j])
    tmp3 = abs(s1+s2)
    l.append(tmp3)

ans = min(l)
print(ans)



### FIXED CODE ###

N = int(input())
l = []

for i in range(1,N):
    tmp1 = list(str(i))
    tmp2 = list(str(N-i))
    s1 = 0
    s2 = 0
    for j in range(len(tmp1)):
        s1 += int(tmp1[j])
    for j in range(len(tmp2)):
        s2 += int(tmp2[j])
    tmp3 = abs(s1+s2)
    l.append(tmp3)

ans = min(l)
print(ans)
def search_obj(x,y,grids):
    ans = [0,0]
    curr_state = grids[y][x]
    grids[y][x] = '0'    
    obj_state = '.'
    if(curr_state == '.'):
        ans[0] += 1
        obj_state = '#'
    elif(curr_state == '#'):
        ans[1] += 1
    
    if(grids[y-1][x] == obj_state):
        a,b = search_obj(x,y-1,grids)
        ans[0] += a
        ans[1] += b

    if(grids[y][x-1] == obj_state):
        a,b = search_obj(x-1,y,grids)
        ans[0] += a
        ans[1] += b

    if(grids[y+1][x] == obj_state):
        a,b = search_obj(x,y+1,grids)
        ans[0] += a
        ans[1] += b

    if(grids[y][x+1] == obj_state):
        a,b = search_obj(x+1,y,grids)
        ans[0] += a
        ans[1] += b

    return ans
    

H,W = (int(x) for x in input().split())
s = ""
ans = 0
for _ in range(W+2):
    s+="0"
s = list(s)
grids = [s]

for _ in range(H):
    si = input()
    si = "0"+si+"0"
    grids.append(list(si))
    
grids.append(s)

for i in range(W):
    for j in range(H):
        a,b = search_obj(i+1,j+1,grids)
        ans += a*b

print(ans)



### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

def search_obj(x,y,grids):
    ans = [0,0]
    curr_state = grids[y][x]
    grids[y][x] = '0'    
    obj_state = '.'
    if(curr_state == '.'):
        ans[0] += 1
        obj_state = '#'
    elif(curr_state == '#'):
        ans[1] += 1
    
    if(grids[y-1][x] == obj_state):
        a,b = search_obj(x,y-1,grids)
        ans[0] += a
        ans[1] += b

    if(grids[y][x-1] == obj_state):
        a,b = search_obj(x-1,y,grids)
        ans[0] += a
        ans[1] += b

    if(grids[y+1][x] == obj_state):
        a,b = search_obj(x,y+1,grids)
        ans[0] += a
        ans[1] += b

    if(grids[y][x+1] == obj_state):
        a,b = search_obj(x+1,y,grids)
        ans[0] += a
        ans[1] += b

    return ans
    

H,W = (int(x) for x in input().split())
s = ""
ans = 0
for _ in range(W+2):
    s+="0"
s = list(s)
grids = [s]

for _ in range(H):
    si = input()
    si = "0"+si+"0"
    grids.append(list(si))
    
grids.append(s)

for i in range(W):
    for j in range(H):
        if(grids[j+1][i+1]!='0'):
            a,b = search_obj(i+1,j+1,grids)
            ans += a*b

print(ans)
Copy
Copy
from functools import lru_cache
 
 
N, M = map(int, input().split())
# 壊れている床番号
a = []
for _ in range(M):
    a.append(int(input()))
# ルートの総数
root = 0
# 今いる階段の段数
now = 0
 
 
def isSafe(now):
    """
    1, 2段先共になければ0
    1段先だけあれば1
    2段先だけあれば2
    1, 2段先共にあれば3
    """
    now_1 = not (now-1) in a
    now_2 = not (now-2) in a
    if now<=1:
        return 0
    elif now==2:
        return int(now_1)
    else:
        return int(now_1 + now_2*2)
 
 
@lru_cache(maxsize=100000)
def step(N):
    # N段を登る移動方法数
    if N <= 1:
        if not (1 in a):
            return 1   
        else:
            return 0
    elif N==2:
        if not (2 in a):
            return step(1) + 1
        else:
            return step(1)
    elif isSafe(N)==1:
        return step(N-1)
    elif isSafe(N)==2:
        return step(N-2)
    elif isSafe(N)==3:
        return step(N-1)+step(N-2)
    else:
        return 0
 
print(step(N)%1000000007)

### FIXED CODE ###

def main():
  p, q, r = map(int, input().split())
  print(min(p+q, p+r, q+r))
 
if __name__=='__main__':
  main()
S = input()
#print(len(S))
dire = ['dream','dreamer','erase','eraser']
flag = 0
i=0
j=0
num=0
count = [0]*100
while True:

    tmp = dire[count[num]]
    ind = i

    #if ind + len(dire[j]) <=len(S)+1:
        #print(j)
    for k in range(len(dire[count[num]])):
        if S[ind] != tmp[k]  or  i + len(dire[count[num]]) >=len(S)+1 :
            flag =0
            count[num]  += 1
            break
        else:
            ind = ind + 1
            if k==len(dire[count[num]])-1:
                i = i + len(dire[count[num]])
                num +=1
                flag = 1


    if   count[num] >= 4 and flag == 0:
        count[num] = 0
        num -= 1
        i = i - len(dire[count[num]])
        count[num] += 1

    if i >= len(S):
        print('YES')
        break
    elif count[0]==0 and flag == 0 and i <=0:
        print('NO')
        break


### FIXED CODE ###

S = input()
S_r = S[::-1]
dire = ['dream','dreamer','erase','eraser']
dire_r = [0]*4
for i in range(4):
    tmp = dire[i]
    dire_r[i] = tmp[::-1]
ind = 0

excep = 0

while ind  <len(S_r):
    if excep == 1:
        break
    flag2= 0
    for j in range(4):
        if flag2 ==0:
            case = 0
            for k in range(len(dire_r[j])):
                tmp = dire_r[j]

                if ind + k < len(S_r) and case == 0:
                #    print(j)
            #        print('S:'+S_r[ind+k])
            #        print('dire:'+tmp[k])
                    if S_r[ind+k] != tmp[k]:
                        flag = 0
                        case = 1
                        if j == 3:
                            excep = 1

                    elif k== len(dire_r[j])  -1:
                        ind = ind + len(dire_r[j])
                        flag = 1
                        case = 1
                        flag2 = 1


if flag == 1:
    print('YES')
else:
    print('NO')
k = int(input())

#acd_list = []
all_num = [i for i in range(1,k + 1)]
ans = 0 

#comb_list  = list(itertools.combinations(all_num, 3))
#print(comb_list)

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

result = []
for i in all_num:
  for j in all_num:
    for k in all_num:
      result.append([i, j, k])

for a,b,c in result:
#for a,b,c in comb_list:
    s = gcd(a, b,c)
    ans += s
print(ans)

### FIXED CODE ###

import math
 
k = int(input()) + 1
ans = 0
 
for a in range(1, k):
    for b in range(1, k):
        d = math.gcd(a, b)
        for c in range(1, k):
            ans += math.gcd(d, c)
 
print(ans)
from sys import stdin,stdout
import math
from collections import deque,defaultdict
from math import ceil,floor,inf,sqrt,factorial,gcd,log2
from copy import deepcopy
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
mod=1000000007
ani,total = iia()
if 0<=(4*ani-total)<=2*ani:
    print('Yes')
else:
    print('No'

### FIXED CODE ###

from sys import stdin,stdout
import math
from collections import deque,defaultdict
from math import ceil,floor,inf,sqrt,factorial,gcd,log2
from copy import deepcopy
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
mod=1000000007
ani,total = iia()
if total>4*ani:
    print('No')
elif total % 2==0:
    crane=(4*ani - total)
    tor = total-2*ani
    if crane%2==0 or tor%2==0:
        if 0<=crane//2<=ani and 0<=tor//2<=ani:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')
a , b = map(int, input().split())

if (a <= b * 2):
  print 0
else:
  print a - b * 2

### FIXED CODE ###

a , b = map(int, input().split())

if (a <= b * 2):
  print (0)
else:
  print (a - b * 2)
N, K = input().split()
N[K] = N[K].lower()
print(N)


### FIXED CODE ###

N, K = map(int,input().split())
S = input()
S = list(S)
S[K-1] = S[K-1].lower()
print(''.join(S))
n,m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()

dis=[]
res=0
if n>m: 
    print(0)
else:
    for i in range(len(x)-1):
        dis[i] = x[i+1] - x[i]

    dis.sort()

    for j in range(n-1):
        res += y[j]

    print(sum(dis) - res)

### FIXED CODE ###

n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
d = [x[i] - x[i-1] for i in range(1, m)]
d.sort()
print(sum(d[:m-n]) if m >= n else 0)
import sympy

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

cnt = [0]*200010

b = []

for i in reversed(range(n)):

	num = i + 1
	if cnt[num]%2 != a[num-1]:
		b.append(num)
		divs = sympy.divisors(num)

		for div in divs:
			cnt[div] += 1

print(len(b))
b.sort()

for i in b:
	print(str(i)+' ',end='')

print()

### FIXED CODE ###

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

cnt = [0]*200010

b = []

for i in reversed(range(n)):

	num = i + 1
	if cnt[num]%2 != a[num-1]:
		b.append(num)
		j = 1
		while j*j <= (num):
			if num%j==0 :
				cnt[j] += 1
				if num//j != j:
					cnt[num//j]+=1
			j = j +1


print(len(b))
b.sort()

for i in b:
	print(str(i)+' ',end='')

print()
s = input()
t = input()

ans = "UNRESTORABLE"

i = 0

while i < len(s)-len(t)+2:
    flag = False
    if s[i] == t[0] or s[i] == "?":
        for j in range(1,len(t)):
            if s[i+j] == "?" or s[i+j] == t[j]:
                flag = True
            else:
                flag = False
                break
        if flag:
            tmps = ""
            k = 0
            while k < len(s):
                if k < i or k >= i+len(t):
                    if s[k] == "?":
                        tmps += "a"
                        k += 1
                    else:
                        tmps += s[k]
                        k += 1
                else:
                    tmps += t
                    k += len(t)
            ans = tmps
    i += 1

print(ans)



### FIXED CODE ###

s = input()
t = input()

ans = "UNRESTORABLE"

ls = []

for i in range(len(t)):
    for j in range(i, len(s)-len(t)+i+1):
        if s[j] == t[i]:
            for k in range(len(t)):
                if t[k] != s[j+k-i] and s[j+k-i] != "?":
                    break
                if k == len(t)-1:
                    tmps = s[:j-i] + t + s[j-i+len(t):]
                    for p in range(len(s)):
                        if tmps[p] == "?":
                            tmps = tmps[:p] + "a" + tmps[p+1:]
                    ls.append(tmps)

for i in range(len(s)-len(t)+1):
    if s[i] == "?":
        if s[i:i+len(t)] == "?"*len(t):
            tmps = s[:i] + t + s[i+len(t):]
            for p in range(len(s)):
                if tmps[p] == "?":
                    tmps = tmps[:p] + "a" + tmps[p+1:]
            ls.append(tmps)

ls.sort()
if len(ls) != 0:
    ans = ls[0]

print(ans)
n = int(input())
tree = [None] * n
formatted_tree = [None] * n


def register_node(i, node, searching):
    if not searching:
        return False
    for si, st in enumerate(searching[1]):
        if st[0] == i:
            searching[1][si] = node
            return True
        elif st[1]:
            if register_node(i, node, st):
                return True
    return False


def format(node, parent, depth):
    (i, cs) = node
    cis = [format(c, i, depth + 1) for c in cs]
    formatted_tree[i] = 'node {0}: parent = {1}, depth = {2}, {3}, [{4}]'.format(
        i, parent, depth,
        'root' if not depth else 'internal node' if cis else 'leaf',
        ', '.join(cis)
    )
    return str(i)


while n:
    l = list(map(int, input().split()))
    i, cs = l[0], l[2:]
    node = (i, [(c, None) for c in cs])
    for p in tree:
        if register_node(i, node, p):
            break
    else:
        tree[i] = node

    for i, ci in enumerate(cs):
        if tree[ci]:
            cs[i] = tree[ci]
            tree[ci] = None

    n -= 1

format(next(filter(None, tree)), -1, 0)

for fn in formatted_tree:
    print(fn)

### FIXED CODE ###

n = int(input())
tree = [None] * n
root = set(range(n))


def set_pd(i, parent, depth):
    node = tree[i]
    node[1], node[2] = parent, depth
    for child in node[0]:
        set_pd(child, i, depth + 1)


while n:
    l = list(map(int, input().split()))
    c = l[2:]
    tree[l[0]] = [c, None, None]
    root -= set(c)
    n -= 1

set_pd(root.pop(), -1, 0)

for i, node in enumerate(tree):
    c, p, d = node
    print('node {}: parent = {}, depth = {}, {}, [{}]'.format(
        i, p, d, 'root' if not d else 'internal node' if c else 'leaf', ', '.join(map(str, c))
    ))
o = input()
e = input()

for i in range(max(len(o),len(e))):
  if 0<=i<len(o):
    print(o(i),end="")
  if 0<=i<len(e):
    print(e(i), end="")
print()

### FIXED CODE ###

o = input()
e = input()

for i in range(max(len(o),len(e))):
  if 0<=i<len(o):
    print(o[i],end="")
  if 0<=i<len(e):
    print(e[i], end="")
print()
s = input()
k = int(input())

slen = len(s)
bstr = '1'*slen

B = int(bstr,2)
f = '0'+str(slen)+'b'
ss = list(s)

a = []
for i in range(B):
  w = ''
  fb = str(format(i, f))
  for i,si in enumerate(list(fb)):
    if si == '1':
      w += ss[i]
      
  if w != '' and w not in a:
    a.append(w)
    
a = sorted(a)
print(a[k-1])

### FIXED CODE ###

s = input()
k = int(input())
a = []
for i in range(len(s)):
  for j in range(1, k+1):
    jj = j+i
    a.append(s[i:jj])
a = sorted(set(a))
print(a[k-1])