Harryxun/stf_run huggingface dataset:
from collections import defaultdict
import sys
input = sys.stdin.readline
N, M, K = map(int, input().split())

def dfs(v):
    size = 1
    for w in fr[v]:
        if ~roots[w]: continue
        roots[w] = roots[v]
        size += dfs(w)
    return size

fr = defaultdict(set)
for _ in range(M):
    a, b = [int(x) -1 for x in input().split()]
    fr[a].add(b)
    fr[b].add(a)
bl = defaultdict(set)
for _ in range(K):
    a, b = [int(x) - 1 for x in input().split()]
    bl[a].add(b)
    bl[b].add(a)

roots = [-1] * N
sizes = [-1] * N

for v in range(N):
    if ~roots[v]: continue
    roots[v] = v
    sizes[v] = dfs(v)

ans = []
for v in range(N):
    w = roots[v]
    res = sizes[w] - len(fr[v]) - sum(1 for u in bl[v] if roots[u] == w) -1
    ans.append(res)

print(*ans)

### FIXED CODE ###

from collections import defaultdict
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
N, M, K = map(int, input().split())

def dfs(v):
    size = 1
    for w in fr[v]:
        if ~roots[w]: continue
        roots[w] = roots[v]
        size += dfs(w)
    return size

fr = defaultdict(set)
for _ in range(M):
    a, b = [int(x) -1 for x in input().split()]
    fr[a].add(b)
    fr[b].add(a)
bl = defaultdict(set)
for _ in range(K):
    a, b = [int(x) - 1 for x in input().split()]
    bl[a].add(b)
    bl[b].add(a)

roots = [-1] * N
sizes = [-1] * N

for v in range(N):
    if ~roots[v]: continue
    roots[v] = v
    sizes[v] = dfs(v)

ans = []
for v in range(N):
    w = roots[v]
    res = sizes[w] - len(fr[v]) - sum(1 for u in bl[v] if roots[u] == w) -1
    ans.append(res)

print(*ans)
#!/usr/local/bin python
# -*- coding: utf-8 -*-
#
# ~/PycharmProjects/atcoder/C-Snack.py
#
import math

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


def lcm(a: int, b: int) -> int:
    return a * b / math.gcd(a, b)


print(int(lcm(a, b)))


### FIXED CODE ###

#!/usr/local/bin python
# -*- coding: utf-8 -*-
#
# ~/PycharmProjects/atcoder/C-Snack.py
#
from fractions import gcd

a, b = map(int, input().split())
ans = int(a * b // gcd(a, b))
print(ans)
while True:
    n,x=map(int,input().split())
    if n==0 and x==0:break
    for i in range(1,n+1):
        for j in range(1,i):
            for k in range(1,j):
                if i+j+k==x:ans+=1
    print(ans)



### FIXED CODE ###

while True:
    n,x=map(int,input().split())
    a=0
    if n==0 and x==0:break
    for i in range(1,n+1):
        for j in range(1,i):
            for k in range(1,j):
                if i+j+k==x:a+=1
    print(a)
S = input()
K = int(input())
counter = 0
for i in S:
    if int(i) != 1:
        log = counter
        num = int(i)
        break
    counter += 1

if K <= log:
    print(1)
else:
    print(num)


### FIXED CODE ###

S = input()
K = int(input())
counter = 0
num = 1
log = 0
for i in S:
    if int(i) != 1:
        log = counter
        num = int(i)
        break
    counter += 1

if K <= log:
    print(1)
else:
    print(num)
N=int(input())
S=input()
count=0
if N%2!=0:
  print("No")
else:
  for i in range(len(S)/2):
    if S[i]!=S[len(S)/2+i]:
      print("No")
      break
    count+=1
  if count==len(S)/2:
    print("Yes")

### FIXED CODE ###

N=int(input())
S=input()
if N%2!=0:
  print("No")
else:
  half=N//2-1
  T1=[]
  T2=[]
  for i in range(half+1):
    T1.append(S[i])
  for j in range(half+1,len(S)):
    T2.append(S[j])
  if T1==T2:
      print("Yes")
  else:
      print("No")
s = input()
ans = ""
for i in range(len(s),2):
  ans += s[i]
print(ans)


### FIXED CODE ###

s = input()
ans = ""
for i in range(0,len(s),2):
  ans += s[i]
print(ans)
import sys,heapq
input=sys.stdin.readline
N,M=[int(x) for x in input().strip().split()]
AB=[list(map(int,input().strip().split())) for _ in range(N)]
AB.sort()
print(AB)
n=0
sumB=0
q=[]
for m in range(1,M+1):
    maxB=0
    while n<N and AB[n][0]<=m:
        heapq.heappush(q,-AB[n][1])
        n+=1
    sumB+=heapq.heappop(q)
    if len(q)==0: break
    
print(-sumB)

### FIXED CODE ###

import sys,heapq
input=sys.stdin.readline
N,M=[int(x) for x in input().strip().split()]
AB=[list(map(int,input().strip().split())) for _ in range(N)]
AB.sort()
n=0
sumB=0
q=[]
for m in range(1,M+1):
    while n<N and AB[n][0]<=m:
        heapq.heappush(q,-AB[n][1])
        n+=1
    if len(q)!=0:
        sumB+=heapq.heappop(q)

print(-sumB)
N = int(input())
H = list(map(int, input().split()))
counts = []

for i in range(N):
    count = 0
    for j in range(i+1, N):
        if H[i] < H[j]:
            break
        count += 1
    counts.append(count)

print(max(count))

### FIXED CODE ###

N = int(input())
H = list(map(int, input().split()))
count = 0
counts = []

if N <= 1:
    counts.append(0)
else:
    for i in range(N-1):
        if H[i] >= H[i+1]:
            count += 1
        else:
            counts.append(count)
            count = 0
    else:
        counts.append(count)

print(max(counts))
n=int(input())
txylist=[[0,0,0,]]
for i in range(n):
    txy=list(map(int,input().split(" ")))
    txylist+=[txy]
if n==1:
    t1,x1,y1=txylist[2]
    if t==abs(x1)+abs(y1):
        p=True
    else:
        print("No")
else:
    for i in range(n):
        p=False
        t0,x0,y0=txylist[i]
        t1,x1,y1=txylist[i+1]
        t=t1-t0
        x=x1-x0
        y=y1-y0
        longs=abs(x)+abs(y)
        if longs==t:
            p=True
        else:
            print("No")
            break
if p==True:
    print("Yes")

### FIXED CODE ###

n=int(input())
txylist=[[0,0,0]]
for i in range(n):
    txy=list(map(int,input().split(" ")))
    txylist+=[txy]
for i in range(n):
    p=False
    t0,x0,y0=txylist[i]
    t1,x1,y1=txylist[i+1]
    t=t1-t0
    x=x1-x0
    y=y1-y0
    tt=abs(x)+abs(y)
    legs=t-tt
    if legs>=0 and legs%2==0:
        p=True
    else:
        print("No")
        break
if p==True:
    print("Yes")
X = input()
nfh = X // 500
nf = (X - 500 * nfh) // 5
happy = 1000 * nfh + 5 * nf
print(happy)

### FIXED CODE ###

X = int(input())
nfh = X // 500
nf = (X - 500 * nfh) // 5
happy = 1000 * nfh + 5 * nf
print(happy)
n = int(input())
A = list(map(int, input().split()))
setA = set(A)
listSetA = list(setA)

if A == [0 for i in range(n)]:
    print("Yes")
elif len(setA) == 2 and listSetA[0] == 0 and 2*A.count(0) == A.count(listSetA[1])
elif len(setA) == 3 and listSetA[0] ^ listSetA[1] == listSetA[2] and A.count(listSetA[0]) == A.count(listSetA[1]) == A.count(listSetA[2]):
    print("Yes")
else:
    print("No")


### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))
setA = set(A)
listSetA = list(setA)

if A == [0 for i in range(n)]:
    print("Yes")
elif len(setA) == 2 and listSetA[0] == 0 and 2*A.count(0) == A.count(listSetA[1]):
    print("Yes")
elif len(setA) == 3 and listSetA[0] ^ listSetA[1] == listSetA[2] and A.count(listSetA[0]) == A.count(listSetA[1]) == A.count(listSetA[2]):
    print("Yes")
else:
    print("No")
n,m=map(int,input().split())

a_lis=[list(map(int,input())) for i in range(n)]
c_lis=[list(map(int,input())) for i in range(m)]

for i in range(n):
  num=0
  ans=10**10
  for j in reversed(range(m)):
    a=a_lis[i]
    c=c_lis[j]
    num=abs(a[0]-c[0])+abs(a[1]-c[1])
    ans=min(ans,num)
    if num==ans:
      cnt=j+1
  print(cnt)
    

### FIXED CODE ###

n,m=map(int,input().split())

a_lis=[list(map(int,input().split())) for i in range(n)]
c_lis=[list(map(int,input().split())) for i in range(m)]

for i in range(n):
  num=0
  ans=10**10
  for j in reversed(range(m)):
    a=a_lis[i]
    c=c_lis[j]
    num=abs(a[0]-c[0])+abs(a[1]-c[1])
    ans=min(ans,num)
    if num==ans:
      cnt=j+1
  print(cnt)
while True:
    H, W = [int(i) for i in input().split()]
    if H == w == 0:
        break
    
    for i in range(H):
        for w in range(W):
            print('#',end='')
            
        print('#', end='')
    
    print()
    
print()

### FIXED CODE ###

while True:
    H, W = [int(i) for i in input().split()]
    if H == W == 0:
        break
    
    for h in range(H):
        for w in range(W):
            print('#', end='')
        print()
    
    print()
#!/usr/bin/env python
import bisect
from collections import defaultdict

def main():
    N, M = map(int, input().split())
    As = set([int(input()) for i in range(M)])
    BIG_NUM = 1000000007

    prev_prev_step = 1
    if 1 in As:
        prev_step = 0
    else:
        prev_step = 1

    for i in range(2, N+1):
        if i in As:
            current_step = 0
        else:
            current_step = (prev_step + prev_prev_step) % BIG_NUM
        prev_prev_step = prev_step
        prev_step = current_step

    print(current_step)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python
import bisect
from collections import defaultdict

def main():
    N, M = map(int, input().split())
    As = set([int(input()) for i in range(M)])
    BIG_NUM = 1000000007

    current_step = 0
    prev_prev_step = 1
    if 1 in As:
        prev_step = 0
    else:
        prev_step = 1
        current_step = 1

    for i in range(2, N+1):
        if i in As:
            current_step = 0
        else:
            current_step = (prev_step + prev_prev_step) % BIG_NUM
        prev_prev_step = prev_step
        prev_step = current_step

    print(current_step)

if __name__ == '__main__':
    main()
n = int(input())

string = input()

if n%2 /= 0:
  print('No')
else:
  if string[:n/2] == string[n/2:]:
    print('Yes')
  else:
    print('No')

### FIXED CODE ###

#!/usr/bin/python3
# coding: utf-8

# 整数 > 整数型
def I(): return int(input())

# 整数列 '1 2 3 4' > 整数型リスト
def IsIl(): return list(map(lambda x: int(x), input().split()))

# 改行挟む整数列　'1/n 2/n 3/n' > 整数型りすと
def InIl(n): return [input() for i in range(n)]

# 整数列 '1 2' > 整数型タプル
def IsIt(): return map(lambda x: int(x), input().split())

# 改行挟む整数列　'1\n 2\n 3\n' > 整数型たぷる
def InIl(n): return map(input() for i in range(n))

# 文字列 'abcd' > 文字型リスト
def SsSl(): return list(map(lambda x: x, input()))

# 整数 '1234' > 整数型リスト

# 文字列 'aba' > 辞書（文字型:個数）{'a':2,'b':1}
def SSd():
    from collections import defaultdict
    A = input() # [int(i) for i in input().split()]
    dd=defaultdict(int)
    for a in A:
        dd[a]+=1
    return dd

#リストにn個要素を読み込む

# その他アルゴリズムテンプレート
# https://qiita.com/chun1182/items/ddf2b6cba932b2bb0d4e
n = int(input())

string = input()

if n%2 != 0:
  print('No')
else:
  if string[:int(n/2)] == string[int(n/2):]:
    print('Yes')
  else:
    print('No')
a, b, n = map(int, input().split())

ans = -float("inf")
for x in range(n, max(-1, (n - a - 1)*10), -1):
    ans = max(ans, a * x // b - a * (x // b))

print(int(ans))


### FIXED CODE ###

from math import floor

a, b, n = map(int, input().split())
x = min(b - 1, n)
print(floor(a * x / b) - a * floor(x / b))
import numpy as np
n = int(input())
x = [int(i) for i in input().split()]

_list = [-1 for i in range(100)]
for i in range(min(x), max(x), 1):
    a = 0
    for j in range(n):
        a += (x[j]-i)**2
    _list[i] = a
_list = np.array(_list)
print(min(_list[_list>=0]))

### FIXED CODE ###

import numpy as np
n = int(input())
x = [int(i) for i in input().split()]

_list = [-1 for i in range(100)]
if min(x)==max(x):
    print(0)
else:
    for i in range(min(x), max(x), 1):
        a = 0
        for j in range(n):
            a += (x[j]-i)**2
        _list[i] = a
    _list = np.array(_list)
    print(min(_list[_list>=0]))
n, m = map(int, input().split())
A = list(map(int, input().split()))

all_vote = sum(A)

cnt = 0

for a in A:
        if a * 4 * m >= all_vote    #小数になる可能性をなくした
        cnt += 1
if cnt >= m:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

n, m = map(int, input().split())
A = list(map(int, input().split()))

all_vote = sum(A)

cnt = 0

for a in A:
    #if a >= all_vote / (4*m):
    if a * 4 * m >= all_vote:   #小数になる可能性をなくした
        cnt += 1
if cnt >= m:
    print('Yes')
else:
    print('No')
a,b,c = map(int,input().split())

s = sum(a,b,c)

print(s-max(a,b,c))

### FIXED CODE ###

a,b,c = map(int,input().split())
 
s = a+b+c
 
print(s-max(a,b,c))
N, M = map(int, input().split())
g = [[] for _ in range(M + 1)]
for _ in range(M):
    a, b = map(int, input().split())
    g[a].append(b)
    g[b].append(a)

ans = 0
def walk(cur, visited):
    global ans
    tmp = visited + [cur]
    if len(tmp) == N:
        ans += 1
    for nex in g[cur]:
        if nex not in tmp:
            walk(nex, tmp)
walk(1, [])
print(ans)

### FIXED CODE ###

n, m = map(int, input().split())
g = [[]for _ in range(n + 1)]
for _ in range(m):
    a, b = map(int, input().split())
    g[a].append(b) 
    g[b].append(a)

ret = 0
def walk(node, visited):
    global ret
    tmp = visited + [node]
    if len(tmp) == n:
        ret += 1 
    for nd in g[node]:
        if nd not in tmp:
            walk(nd, tmp)
walk(1, [])
print(ret)
import math

def main():

    a,b,h,m = map(int,input().split())
    kakub = 6.0*m
    kakua = 30.0*h + (30.0*(m/60.0))
    maxx = max(kakua,kakub)
    minn = min(kakua,kakub)
    if (maxx - 180.0) > minn:
        aug = (360.0 - maxx) + minn
    elif (maxx - 180.0) < minn:
        aug = maxx - minn

    ans = (a**2.0) + (b**2.0) -( (2.0*a*b)*math.cos(math.radians(aug)) )
    print(math.sqrt(ans))



if __name__=='__main__':
    main()

### FIXED CODE ###

import math

def main():

    a,b,h,m = map(int,input().split())
    kakub = 6.0*m
    kakua = 30.0*h + (30.0*(m/60.0))
    maxx = max(kakua,kakub)
    minn = min(kakua,kakub)
    if (maxx - 180.0) > minn:
        aug = (360.0 - maxx) + minn
    elif (maxx - 180.0) < minn:
        aug = maxx - minn
    else:
        aug = 180.0
    
    if aug == 180.0:
        ans=a+b
        print(ans)
    
    else: 
        ans = (a**2.0) + (b**2.0) -( (2.0*a*b)*math.cos(math.radians(aug)) )
        print(math.sqrt(ans))



if __name__=='__main__':
    main()
import sys

for line in sys.stdin:
    A=line.split()
    B=map(int,A)

D=B.sort()
e=1

while e != 0:
    e=D[1]%D[0]
    C=D[0]
    D[0]=e
    D[1]=C

print D[0]

### FIXED CODE ###

A=map(int,raw_input().split())
A.sort()

while A[1]%A[0]!=0:
    temp=A[0]
    A[0]=A[1]%A[0]
    A[1]=temp

print A[0]
import networkx as nx
import matplotlib.pyplot as plt
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, k = LI()
B = [0] * n
for _ in range(k):
    d = I()
    A = LI()
    for a in A:
        B[a - 1] = 1

ans = 0
for i in range(n):
    if B[i] == 0:
        ans += 1

print(ans)


### FIXED CODE ###

from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, k = LI()
B = [0] * n
for _ in range(k):
    d = I()
    A = LI()
    for a in A:
        B[a - 1] = 1

ans = 0
for i in range(n):
    if B[i] == 0:
        ans += 1

print(ans)
n = str(input())
if int(n)==10000:
    print(0)
else:
    print(1000-int(n[1:4]))

### FIXED CODE ###

n = int(input())

if n <= 1000:
    print(1000-n)
elif 1000< n <=2000:
    print(2000-n) 
elif 2000< n <=3000:
    print(3000-n)
elif 3000< n <=4000:
    print(4000-n)
elif 4000< n <=5000:
    print(5000-n)
elif 5000< n <=6000:
    print(6000-n)
elif 6000< n <=7000:
    print(7000-n)
elif 7000< n <=8000:
    print(8000-n)
elif 8000< n <=9000:
    print(9000-n)
elif 9000< n <=10000:
    print(10000-n)
#
import sys
import math
import numpy as np
import itertools

n = int(input())
a=[]
b=[]
c=[]
d=[]
for j in range(0,n):
    t1,t2,t3,t4 = (int(i) for i in input().split())  
    a.append(t1)
    b.append(t2)
    c.append(t3)
    d.append(t4)
    
for i in range(0,n):
    if a[i] < b[i]:
        print("No")
    elif d[i] < b[i]:
        print("No")
    else:
        flag=1
        p= math.gcd(b[i],d[i])
        if (b[i]-p)+a[i]%p > c[i]:
            print("No")
        else:
            print("Yes")
    



### FIXED CODE ###

#
import sys

n = int(input())
a=[]
b=[]
c=[]
d=[]
for j in range(0,n):
    t1,t2,t3,t4 = (int(i) for i in input().split())  
    a.append(t1)
    b.append(t2)
    c.append(t3)
    d.append(t4)
    
for i in range(0,n):
    if a[i] < b[i]:
        print("No")
    elif d[i] < b[i]:
        print("No")
    else:
        p= b[i]
        q= d[i]
        while p%q :
            r=q
            q=p%q
            p=r
        if (b[i]-q)+a[i]%q > c[i]:
            print("No")
        else:
            print("Yes")
n = int(input())
s = [list(map(int, input().split())) for _ in range(n)]
if not n == 1:
    for i in range(101):
        for j in range(101):
            c = s[0][2] + abs(i - s[0][0]) + abs(j - s[0][1])
            d = 0
            for k in range(1, n):
                if not abs(i - s[k][0]) + abs(j - s[k][1]) == c - s[k][2]:
                    d = 1
                    break
            if d == 0:
                ans = [i, j, c]
                break
else:
    ans = s[0]
print(" ".join(map(str, ans)))

### FIXED CODE ###

n = int(input())
if n == 1:
    x, y, h = map(int, input().split())
    print(x, y, h)
    exit()
s = [list(map(int, input().split())) for _ in range(n)]
for i in range(101):
    for j in range(101):
        h = -1
        ok = 1
        for t in s:
            if t[2] == 0:
                ok += 1
            elif h == -1:
                h = abs(t[0] - i) + abs(t[1] - j) + t[2]
            else:
                h0 = abs(t[0] - i) + abs(t[1] - j) + t[2]
                if h == h0:
                    ok += 1
        if ok == n:
            for t in s:
                if abs(t[0] - i) + abs(t[1] - j) <= h:
                    if not h == abs(t[0] - i) + abs(t[1] - j) + t[2]:
                        ok = 0
                else:
                    if not t[2] == 0:
                        ok = 0
            if ok == n:
                print(i, j, h)
                exit()
from math import pi
r = int(input())
print(format(r * r * pi, '.6f'), format(r * 2 * pi, '.6f'))

### FIXED CODE ###

from math import pi
r = float(input())
print(format(r * r * pi, '.6f'), format(r * 2 * pi, '.6f'))
N = int(input())
a = list(map(int,input().split()))

count = 0
A = 0
B = 0

while count < N+1 and len(a) >0: 
	m = max(a)
	A += m
	a.remove(m)  
	if len(a) > 0:
		m = max(a)
		B += m
		a.remove(m)
	count +=1

print(A - B)

### FIXED CODE ###

nums = input().split()
N = int(nums[0])
A = int(nums[1])
B = int(nums[2])

n = 0
ans = 0
while n < N+1:
	n4 = n // 10**4
	n3 = n // 10**3 - n4 * 10
	n2 = n // 10**2 - n4 * 100 - n3 * 10
	n1 = n // 10 - n4 * 1000 - n3 * 100 - n2 * 10
	n0 = n % 10
	X = n4 + n3 + n2 + n1 + n0
	if X >= A and X <= B:     
		ans += n 
	n += 1

print(ans)
s = input()
st = input()
mx=10**9

rangeforloop= len(s)+1 - len(st)
 
for i in range(rangeforloop):
    mx=min(mx,matcher(s[i:len(st+i)], st))
    
     
print(mx)

### FIXED CODE ###

def matcher(s1,s2):
    match=0
    for i in range(len(s1)):
        if(s1[i]!=s2[i]):
            match+=1
            
    return match

#print(matcher("eforces","atcoder"))

s = input()
st = input()
mx=10**5

rangeforloop= len(s)+1 - len(st)
 
for i in range(rangeforloop):
    mx=min(mx,matcher(s[i:len(st)+i], st))
    
     
print(mx)
while True:
     k = input()
     if 1 <= int(k) <= 100:
         break;
     print ('Error Invalid Input for K')

#Check constraint for K


while True:
     s = input().lower()
     if 1 <= len(s) <= 100:
         break;
     print ('Error Invalid Input for s')

#Check constraint for S

if len(s) > k:
    print(s[:k] + "...")
else:
    print(s)

### FIXED CODE ###

# Take both input K & S, then compare the length of S with K and assign it to length
# If the length is <= K print all
# And if length is >K print some of the character

K = int(input())
S = input()

x = 0

length = len(S)

if length <= K:
    print(S)
else:
    while x < K:
        print(S[x], end=(""))
        x += 1
    print("...")
S=input()
T=input()
n=len(S)
m=len(T)

for i in range(n-m+1,-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")

### FIXED CODE ###

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")
a= []
for i in range(3):
  a_input = input().split()
  a.append(int(a_input))

for i in range(n):
  x = input()
  for j in range(3):
    for k in range(3):
      if x == int(a[j][k]):
        a[j][k] = "0"

for i in range(3):
    if a[0][i] == "0" and a[0][i] == a[1][i] and a[0][i] == a[2][i]:
      print("Yes")
    elif a[i][0] == "0" and a[i][0] == a[i][1] and a[i][0] == a[i][2]:
      print("Yes")
    elif a[0][0] == "0" and a[0][0] == a[1][1] and a[1][1] == a[2][2]:
      print("Yes")
    elif a[0][2] == "0" and a[0][2] == a[1][1] and a[0][2] == a[2][0]:
      print("Yes")
    else:
      print("No")

### FIXED CODE ###

a= []
for i in range(3):
  a_input = input().split()
  a.append(a_input)

n = int(input())
for i in range(n):
  x = input()
  for j in range(3):
    for k in range(3):
      if x == a[j][k]:
        a[j][k] = "0"

for i in range(3):
    if a[0][i] == "0" and a[0][i] == a[1][i] and a[0][i] == a[2][i]:
      print("Yes")
      exit()
    elif a[i][0] == "0" and a[i][0] == a[i][1] and a[i][0] == a[i][2]:
      print("Yes")
      exit()
    elif a[0][0] == "0" and a[0][0] == a[1][1] and a[1][1] == a[2][2]:
      print("Yes")
      exit()
    elif a[0][2] == "0" and a[0][2] == a[1][1] and a[0][2] == a[2][0]:
      print("Yes")
      exit()
print("No")
n = int(input())
max_cnt = 0
num_list = [] 
for i in range(n):
  num_list.append(int(input()))
for num in num_list:
  num_cnt = 0
  while True:
    if num % 2 == 1:
      if num_cnt > max_cnt: max_cnt = num_cnt
      break
    else:
      num = num / 2
      num_cnt += 1
print(max_cnt)
 

### FIXED CODE ###

input()
num_list = list(map(int, input().split()))
min_cnt = 999
for num in num_list:
  num_cnt = 0
  while True:
    if num % 2 == 1:
      if num_cnt < min_cnt: min_cnt = num_cnt
      break
    else:
      num = num / 2
      num_cnt += 1
print(min_cnt)
n,t=map(int,input().split());c=[]
for i in range(n):
  a,b=map(int,input().split())
  if b<=t:
    c.append(a)
c.sort();print(c[0])

### FIXED CODE ###

n,t=map(int,input().split());c=[]
for i in range(n):
  a,b=map(int,input().split())
  if b<=t:
    c.append(a)
if c==[]:print("TLE")
else:c.sort();print(c[0])
a,b=map(int,input().split())
s.append(str(a)*b)
s.append(str(b)*a)
s.sort()
print(s[0])

### FIXED CODE ###

a,b=map(int,input().split())
s=[]
s.append(str(a)*b)
s.append(str(b)*a)
s.sort()
print(s[0])