Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

N,K = map(int, input().split())
A = list(map(int, input().split()))
i = N - K
while i > 0:
    print('Yes' if A[K] > A[0] else 'No')
    A.pop(0)
    i -= 1

### FIXED CODE ###

N,K = map(int, input().split())
A = list(map(int, input().split()))
for i in range (K,N):
    print('Yes' if A[i] > A[i-K] else 'No')
### BUGGY CODE ###

import math
K=int(input())

if K%7==0:
    L=9*K//7
else:
    L=9*K

if L%2==0 or L%5==0:
    print(-1)
else:
    num=1
    while 10**num%L!=1:
        num+=1
    print(num)

### FIXED CODE ###

import math
K=int(input())

if K%7==0:
    L=9*K//7
else:
    L=9*K

if L%2==0 or L%5==0:
    ans=-1
else:
    r=10%L
    for i in range(1,10**6+1):
        if r==1:
            ans=i
            break
        else:
            r=10*r%L
print(ans)
### BUGGY CODE ###

x, y, a, b, c = map(int, input().split())
arrayP = list(map(int, input().split()))
arrayQ = list(map(int, input().split()))
arrayR = list(map(int, input().split()))
arrayP.sort(reverse=True)
arrayQ.sort(reverse=True)
arrayR.sort(reverse=True)
arrayAns = []
for i in range(x):
    arrayAns.append(int(arrayP[i]))
for i in range(y):
    arrayAns.append(int(arrayQ[i]))
arrayAns.sort()
for i in range(len(arrayR)):
    if arrayAns[0] <= int(arrayR[i]):
        arrayAns[0] = int(arrayR[i])
        arrayAns.sort()
    else:
        break
print(sum(arrayAns))


### FIXED CODE ###

x, y, a, b, c = map(int, input().split())
arrayP = list(map(int, input().split()))
arrayQ = list(map(int, input().split()))
arrayR = list(map(int, input().split()))
arrayP.sort(reverse=True)
arrayQ.sort(reverse=True)
arrayR.sort(reverse=True)
arrayAns = []
for i in range(x):
    arrayAns.append(int(arrayP[i]))
for i in range(y):
    arrayAns.append(int(arrayQ[i]))
arrayAns.sort()
for i in range(min(len(arrayR), len(arrayAns))):
    if arrayAns[i] <= int(arrayR[i]):
        arrayAns[i] = int(arrayR[i])
    else:
        break
print(sum(arrayAns))
### BUGGY CODE ###

N,K,Q=map(int,input().split())
l=list()
for n in range(Q):
  A=int(input())
  l.append(A)
for n in range(N):
  key=l.count(n+1)
  ans=key+K-Q
  if ans<=0:
    print('No')
  else:
    print('Yes')

### FIXED CODE ###

N,K,Q=map(int,input().split())
l=[K-Q]*N
for n in range(Q):
  A=int(input())
  l[A-1]+=1
for n in range(N):
  if l[n]<=0:
    print('No')
  else:
    print('Yes')
### BUGGY CODE ###

N = int(input())
C = [int(input()) for _ in range(N)]
strC = ''.join(map(str, C))
cntC = []
for num, i in enumerate(strC):
    try:
        cntC.append(strC[0:num].rindex(i) + 1)
    except ValueError:
        cntC.append(-1)
# print(cntC)

dp = [0] * (N + 10)
dp[0] = 1
for i in range(N):
    if cntC[i] == -1 or cntC[i] == i:
        dp[i + 1] = dp[i]
    else:
        dp[i + 1] = dp[i] + dp[cntC[i]]


print(dp[N])

### FIXED CODE ###

N = int(input())
C = [int(input()) for _ in range(N)]
MOD = 10**9 + 7
subC = [-2] * (2 * 10 ** 5 + 10)
cntC = [-1]*N
for num, i in enumerate(C):
    cntC[num] = subC[i]+1
    subC[i] = num

# print(cntC)

dp = [0] * (N + 10)
dp[0] = 1
for i in range(N):
    if cntC[i] < 0 or cntC[i] == i:
        dp[i + 1] = dp[i] % MOD
    else:
        dp[i + 1] = (dp[i] + dp[cntC[i]]) % MOD


print(dp[N])
### BUGGY CODE ###

import heapq
# import collection
# import bisect
# import numpy

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

# N = 10**5
# A = [10 for i in range(10**5)]
# M = 10**5

# A = sorted(A)

heapq.heapify(A)

while M > 0:
    i = heapq.nlargest(1, enumerate(A), key=lambda x: x[1])
    A[i[0][0]] = A[i[0][0]] // 2
    M -= 1

print(sum(A))


### FIXED CODE ###

import heapq
# import collection
# import bisect
# import numpy

N, M = list(map(int, input().split()))
# A = list(map(int, input().split()))

# N = 10**5
# A = [10 for i in range(10**5)]
# M = 10**5

# A = sorted(A)
A = []
for i in input().split():
    heapq.heappush(A, -int(i))

while M > 0:
    heapq.heappush(A, -((-heapq.heappop(A))//2))
    M -= 1

print(-sum(A))
### BUGGY CODE ###

n=int(input())
x=[(int(j),i) for i,j in enumerate(input().split())]
l=int((n-1)/2)

sortedList=sorted(x)
ans=[-1]*n

for i in range(n):
    xx=sortedList[:i]+sortedList[i+1:]
    pos=sortedList[i][1]
    val=xx[l][0]
    ans[pos]=str(val)

print("\n".join(ans))

### FIXED CODE ###

import bisect
n=int(input())
a=list(map(int,input().split()))
b=sorted(a)

left=b[int(n/2)-1]
right=b[int(n/2)]
for i in a:
    pos=bisect.bisect_left(b, i)+1
    if 2*pos<=n:
        print(right)
    else:
        print(left)
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
ans=1
for i in range(N):
    ans=ans*A[i]
if ans>pow(10,18):
    ans='-1'
print(ans)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
A.sort()
if A[0]!=0:
    ans=1
    for i in range(N):
        ans=ans*A[i]
        if ans>pow(10,18):
            ans='-1'
            break
else:
    ans=0
print(ans)
### BUGGY CODE ###

S = list(input())
c = 0
flag = True

while flag:
    flag = False
    for i in range(len(S) - 2):
        if (S[i+2] == 'C') and (S[i+1] == 'B') and (S[i] == 'A'):
            S[i+2], S[i+1], S[i] = 'A', 'C', 'B'
            c += 1
            flag = True
print(c)

### FIXED CODE ###

S = input()
S = S.replace("BC", "D")

c = 0
total = 0

for s in S:
    if s == "A":
        c += 1
    elif s == "D":
        total += c
    else:
        c = 0

print(total)
### BUGGY CODE ###

import math
import numpy as np

def eratos(n):
    if n == 1:
        return 0, 0
    prime_list = []
    #2からnumberまでの数字をsearch_listに入れる
    search_list = list(range(2,n+1))
    while True:
      #search_listの先頭の値が√nの値を超えたら処理終了
        if search_list[0] > math.sqrt(n):
            #prime_listにsearch_listを結合
            prime_list.extend(search_list)
            break
        else:
            #search_listの先頭をprime_listに入れる
            head_num = search_list[0]
            prime_list.append(head_num)
            #search_listの先頭をpopする
            search_list.pop(0)
            #head_numの倍数を取り除く
            search_list = [num for num in search_list if num % head_num != 0]

    p_list = np.array(prime_list)
    p_like = (p_list + 1) // 2
    inter = np.intersect1d(p_list, p_like)

    if (p_list[-1] + 1) // 2 == inter[-1]:
        return len(inter), 1
    else:
        return len(inter), 0


def main():
    Q = int(input())
    l = [None]*Q
    r = [None]*Q
    for i in range(Q):
        l[i], r[i] = map(int, input().split())
    
    for i in range(Q):
        R, _ = eratos(r[i])
        L, me = eratos(l[i])
        #print(l[i], L, r[i], R)
        print(R - L + me)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import math
import numpy as np

n = 10**5 + 1
p = [False] * n
c = [0] * n

def main():
    # 2からnまでの数字をsearch_listに入れる
    search_list = list(range(2,n))
    while True:
        # search_listの先頭の値が√nの値を超えたら処理終了
        if search_list[0] > math.sqrt(n):
            # search_listの残りの素数フラグを立てる
            for num in search_list:
                p[num] = True
            break
        else:
            # search_listの先頭の素数フラグを立てる
            tmp = search_list[0]
            p[tmp] = True
            # search_listの先頭をpopする
            search_list.pop(0)
            # search_listの先頭の倍数を取り除く
            search_list = [num for num in search_list if num % tmp != 0]

    # 1以上i以下のN-like数の数をc[i]とする
    for i in range(1,n):
        if p[i] and p[(i+1)//2]:
            c[i] = c[i-1] + 1
        else:
            c[i] = c[i-1]


    Q = int(input())
    for i in range(Q):
        l, r = map(int, input().split())
        print(c[r] - c[l-1])
    

if __name__ == "__main__":
    main()
### BUGGY CODE ###

N,K = map(int,input().split())
ds = list(map(int,input().split()))
out = 0
for i in range(N-K+1):
    out = max(out,sum(ds[i:i+K]))
print((out+K)/2)

### FIXED CODE ###

import queue
q = queue.Queue()
N,K = map(int,input().split())
ds = list(map(int,input().split()))

sm = sum(ds[:K])
out = sm
for i in range(N-K):
    sm = sm-ds[i]+ds[i+K]
    out = max(out,sm)

print((out+K)/2)
### BUGGY CODE ###

import math

def main(A, B, N):
    answer = 0
    for x in range(N + 1):
        cand = math.floor(A * x / B) - A * math.floor(x / B)
        answer = max(answer, cand)
    print(answer)



if __name__ == '__main__':
    A, B, N = list(map(int, input().split()))
    # A, B, N = 5, 7, 4
    main(A, B, N)


### FIXED CODE ###

import math

def main(A, B, N):
    x = min(B-1, N)
    answer = math.floor(A * x / B) - A * math.floor(x / B)
    print(answer)

if __name__ == '__main__':
    A, B, N = list(map(int, input().split()))
    main(A, B, N)
### BUGGY CODE ###


pattern = "simple"

n = int(input())

if pattern == "simple":
    
    max_sum = -1

    for i in range(10**(len(str(n))-1)-1, n+1):
        
        i_parts = []
        for i_part in str(i):
            i_parts.append(int(i_part))

        this_sum = sum(i_parts)
        
        if max_sum < this_sum:
            max_sum = this_sum
            max_sum_i = i

    # print("max_sum  : {}\nmax_sum_i: {}".format(max_sum, max_sum_i))
    print(max_sum)

elif pattern == "temp":
    max_sum_i = int(str(n)[0]) * 10**(len(str(n))-1) -1
    max_sum = sum([int(i) for i in str(max_sum_i)])

    # print("max_sum  : {}\nmax_sum_i: {}".format(max_sum, max_sum_i))
    print(max_sum)

### FIXED CODE ###

n = int(input())

def digit_sum_simple(n):
    
    max_sum = -1

    for i in range(10**(len(str(n))-1)-1, n+1):
        
        i_parts = []
        for i_part in str(i):
            i_parts.append(int(i_part))

        this_sum = sum(i_parts)
        
        if max_sum < this_sum:
            max_sum = this_sum
            max_sum_i = i

    return max_sum, max_sum_i

def digit_sum_temp(n):
    max_sum_i = int(str(int(str(n+1)[0])-1) + "9"*(len(str(n+1))-1))
    max_sum = sum([int(j) for j in str(max_sum_i)])

    return max_sum

print(digit_sum_temp(n))
### BUGGY CODE ###

import bisect

n = int(input())

l = []
for _ in range(n):
    a = int(input())
    i = bisect.bisect_left(l, a)
    if i != len(l) and l[i] == a:
        l.pop(i)
    else:
        l.insert(i, a)

res = len(l)
print(res)

### FIXED CODE ###

n = int(input())

s = set()
for _ in range(n):
    s ^= {input()}

print(len(s))
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
ans = 10 ** 12


def progress():
    for i in range(N):
        for j in range(N):
            if i == j:
                continue
            if (A[j] % A[i] != 0) and (A[j] // A[i]):
                A[j] %= A[i]
                progress()
            if min(A) == 1:
                break
        if min(A) == 1:
            break
    return min(A)

ans = progress()
print(ans)

### FIXED CODE ###

import fractions

N = int(input())
A = list(map(int, input().split()))
B = 0
for i in range(N):
    B = fractions.gcd(B, A[i])
print(B)
### BUGGY CODE ###

from bisect import bisect_left
from itertools import product

a, b, q = [int(i) for i in input().split()]

s_list = [int(input()) for _ in range(a)]
t_list = [int(input()) for _ in range(b)]

n_list = [a, b]
s_t_list = [s_list, t_list]

for _ in range(q):
    x = int(input())

    temp_s_t_list = [[10 ** 11] * 2, [10 ** 11] * 2]
    for i in range(2):
        xi = bisect_left(s_t_list[i], x)

        if xi < n_list[i]:
            temp_s_t_list[i][0] = s_t_list[i][xi] - x
        if xi > 0:
            temp_s_t_list[i][1] = s_t_list[i][xi - 1] - x
    
    temp_list = []
    for s_x, t_x in list(product(temp_s_t_list[0], temp_s_t_list[1])):
        temp_s_x = s_x
        s_x = abs(s_x)
        temp_t_x = t_x
        t_x = abs(t_x)
        if temp_s_x // s_x == temp_t_x // t_x:
            temp_list.append(max(s_x, t_x))
        else:
            temp_list.append(s_x + t_x + min(s_x, t_x))
    print(min(temp_list))

### FIXED CODE ###

from bisect import bisect_left

a, b, q = [int(i) for i in input().split()]

s_list = [int(input()) for _ in range(a)]
t_list = [int(input()) for _ in range(b)]

for _ in range(q):
    x = int(input())

    temp_s_t_list = [10 ** 11] * 4
    
    si = bisect_left(s_list, x)
    if si < a:
        temp_s_t_list[0] = s_list[si] - x
    if si > 0:
        temp_s_t_list[1] = s_list[si - 1] - x
    
    ti = bisect_left(t_list, x)
    if ti < b:
        temp_s_t_list[2] = t_list[ti] - x
    if ti > 0:
        temp_s_t_list[3] = t_list[ti - 1] - x

    ans = 10 ** 11 * 3
    for s_x, t_x in [(temp_s_t_list[0], temp_s_t_list[2]), (temp_s_t_list[0], temp_s_t_list[3]), (temp_s_t_list[1], temp_s_t_list[2]), (temp_s_t_list[1], temp_s_t_list[3])]:
        temp_s_x = s_x
        s_x = abs(s_x)
        temp_t_x = t_x
        t_x = abs(t_x)
        if temp_s_x // s_x == temp_t_x // t_x:
            temp = max(s_x, t_x)
        else:
            temp = s_x + t_x + min(s_x, t_x)

        if ans > temp:
            ans = temp
    print(ans)
### BUGGY CODE ###

#!/usr/bin/env python3
from fractions import gcd
from functools import reduce

N = int(input())

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

L = reduce((lambda x, y: x // gcd(x, y) * y), A)

res = 0

MOD = 10**9+7

for a in A:
  res = (res + L//a % MOD) % MOD

print(res)


### FIXED CODE ###

#!/usr/bin/env python3
from fractions import gcd
from functools import reduce

N = int(input())

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

MOD = 10**9+7

L = reduce((lambda x, y: x // gcd(x, y) * y), A) % MOD

res = 0

def modulo(x, y):
  tmp = x % y
  if tmp < 0: tmp += y
  return tmp

def extgcd(x, y):
  if x < y:
    a, b = extgcd(y, x)
    return b, a
  if y == 0 or x % y == 0: return 0, 1
  a, b = extgcd(y, modulo(x , y))
  return (b, -(x // y) * b + a)

def inv(x):
  a, _ = extgcd(x,MOD)
  return modulo(a, MOD)

for a in A:
  res = (res + L* inv(a) % MOD) % MOD

print(res)
### BUGGY CODE ###

c1 = list(map(int,input().split()))
c2 = list(map(int,input().split()))
c3 = list(map(int,input().split()))


for a in range(0,101):
    for b in range(0,101):
        for c in range(0,101):
            for d in range(0,101):
                for e in range(0,101):
                    for f in range(0,101):
                        a1 = f
                        a2 = e
                        a3 = d
                        b1 = c
                        b2 = b
                        b3 = a
                        if a1 + b1 == c1[0] and a1 +b2 == c1[1] and a1 + b3 ==c1[2] \
                            and a2 + b1 == c2[0] and a2 +b2 == c2[1] and a2 + b3 ==c2[2] \
                                and a3 + b1 == c3[0] and a3 +b2 == c3[1] and a3 + b3 ==c3[2]:
                                print("Yes")
                                exit()
print("No")


### FIXED CODE ###

c1 = list(map(int,input().split()))
c2 = list(map(int,input().split()))
c3 = list(map(int,input().split()))


for a in range(0,101):
    for b in range(0,101):
        for c in range(0,101):
                        a1 = a
                        a2 = b
                        a3 = c
                        b1 = c1[0] - a1
                        b2 = c1[1] - a1
                        b3 = c1[2] - a1
                        if a1 + b1 == c1[0] and a1 +b2 == c1[1] and a1 + b3 ==c1[2] \
                            and a2 + b1 == c2[0] and a2 +b2 == c2[1] and a2 + b3 ==c2[2] \
                                and a3 + b1 == c3[0] and a3 +b2 == c3[1] and a3 + b3 ==c3[2]:
                                print("Yes")
                                exit()
print("No")
### BUGGY CODE ###

# input
N = int(input())
S = input()

# process
R = []
G = []
B = []
for i, s in enumerate(list(S)):
    if s == 'R':
        R.append(i)
    elif s == 'G':
        G.append(i)
    else:
        B.append(i)

ans = len(R)*len(G)*len(B)
for r in R:
    for g in G:
        i, j = r, g
        if i > j:
            i, j = j, i
        
        s = j-i
        t1 = -1
        if s%2 == 0:
            t1 = i+s//2
        t2 = i-s
        t3 = j+s
        
        for b in B:
            if b in (t1, t2, t3):
                ans -= 1

# output
print(ans)


### FIXED CODE ###

# input
N = int(input())
S = input()

# process
ans = S.count('R')*S.count('G')*S.count('B')
for i in range(N):
    for j in range(N):
        if i-j<0 or i+j >= N:
            break
        x = S[i-j]
        y = S[i]
        z = S[i+j]

        if x!= y and x != z and y != z:
            ans -= 1
            
# output
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

N, M = map(int, input().split())
G = [[] for _ in range(N)]

for _ in range(M):
    s, t = map(int, input().split())
    G[s-1].append(t-1)

ans = 10000

for block in range(-1, N-1):
    dp = [0]*N
    
    for v in range(N-2, -1, -1):
        M = 0
        cnt = 0
        
        for nv in G[v]:
            M = max(M, dp[nv])
            dp[v] += dp[nv]
            cnt += 1
        
        if block==v and cnt>=2:
            dp[v] -= M
            cnt -= 1
        
        dp[v] /= cnt
        dp[v] += 1

    ans = min(ans, dp[0])

print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline

def calc(ban_s, ban_t):
    dp2 = [0]*N
    dp2[N-1] = 0
    
    for v in range(N-2, -1, -1):
        cnt = 0
        
        for nv in G[v]:
            if v==ban_s and nv==ban_t:
                continue
            
            dp2[v] += dp2[nv]+1
            cnt += 1
        
        if cnt==0:
            dp2[v] = 100000
        else:
            dp2[v] /= cnt
        
    return dp2[0]
    
N, M = map(int, input().split())
G = [[] for _ in range(N)]

for _ in range(M):
    s, t = map(int, input().split())
    G[s-1].append(t-1)

dp = [0]*N
dp[N-1] = 0

for v in range(N-2, -1, -1):
    for nv in G[v]:
        dp[v] += dp[nv]+1
    
    dp[v] /= len(G[v])

ans = dp[0]

for v in range(N):
    M = 0
    mark = -1
    
    for nv in G[v]:
        if dp[nv]>M:
            M = dp[nv]
            mark = nv
    
    ans = min(ans, calc(v, mark))

print(ans)
### BUGGY CODE ###

n = int(input())
s = input()

ans = 0
for i in range(n):
    x = s[i]
    for j in range(i, n):
        if s[j] != x:
            y = s[j]
            for k in range(j, n):
                if s[k] not in (x, y) and j-i != k-j:
                    ans += 1

print(ans)

### FIXED CODE ###

n = int(input())
s = input()

r, g, b = 0, 0, 0
for si in s:
    if si == "R":
        r += 1
    elif si == "G":
        g += 1
    else:
        b += 1
        
ans = r * g * b

d = 0
for i in range(n-2):
    for j in range(i, n-1):
        k = j + j - i
        if k < n and s[i] != s[j] and s[k] not in (s[i], s[j]):
            d += 1
        
print(ans - d)
### BUGGY CODE ###

from functools import reduce
S = list(map(int,input().rstrip()))
l=len(S)
result=0
for i in range(0,int(l-3)):
    for j in range(i+4,int(l+1)):
        n = reduce( lambda a,b:10*a+b, S[i:j])
        if n %673==0 and n%3==0:
            result+=1
print(result)

### FIXED CODE ###

# coding: utf-8
# Your code here!
def main():
    from functools import reduce
    import collections
     
    S = list(map(int,input().rstrip()))
    N=len(S)
    mod_list = [0]
    for i in range(1,N+1):
        new1 =pow(10,i-1,2019)
        new = (new1*S[-i]+mod_list[-1])%2019
        #print(new)
        mod_list.append(new)
        
    count = collections.Counter(mod_list)
    ans =0
    for j in range(2019):
        n = count[j]
        ans+= n*(n-1)/2
    print(int(ans))
if __name__ == "__main__":
    main()
### BUGGY CODE ###

N,K=map(int,input().split())
x=list(map(int,input().split()))
ans=10000000000000000000
for i in range(0,N-K+1):
    ls=0
    rs=0

    for j in range(i,i+K):
        if(x[j]<0):
            ls=max(abs(x[j]),ls)
        else:
            rs=max(abs(x[j]),rs)
    ans=min(ls+rs+min(ls,rs),ans)

print(ans)

### FIXED CODE ###

N,K=map(int,input().split())
x=list(map(int,input().split()))
ans=10000000000000000000
for i in range(0,N-K+1):
    ls=(x[i])
    rs=(x[i+K-1])
    if(ls>0 and rs>0):
        ans=min(ans,rs)
    elif(ls<0 and rs<0):
        ans=min(ans,abs(ls))
    else:
        ans=min(abs(ls)+rs+min(abs(ls),rs),ans)

print(ans)
### BUGGY CODE ###

s=[int(input())]
i=0
while 1>0:
  if i%2>0:
    b=3*s[i]+1
  else:
    b=s[i]//2
  if b in s:
    print(i+1)
    break


### FIXED CODE ###

s=[int(input())]
i=0
while 1>0:
  if s[i]%2>0:
    b=3*s[i]+1
  else:
    b=s[i]//2
  if b in s:
    print(i+2)
    break
  i+=1
  s+=[b]
### BUGGY CODE ###

n, m  = map(int, input().split())
g     = {}
used  = {i:[False for _ in range(11)] for i in range(n)}
color     = [0  for _ in range(n)]

for _ in range(m):
    u, v = map(int, input().split())
    u-=1
    v-=1
    if u not in g:
        g[u] = []
    if v not in g:
        g[v] = []
    g[u].append(v)
    g[v].append(u)
    
q = int(input())
Q = []

for _ in range(q):
    node, dis, col = map(int, input().split())
    Q.append([node-1, dis, col])
Q = Q[::-1]

def bfs(curQ):
    while len(curQ) > 0:
        node, dis, col = curQ.pop(0)
    
        if used[node][dis] == True:
            continue
            
        if dis < 0:
            continue
            
        used[node][dis] = True
    
        if color[node] == 0:
            color[node] = col

        if node in g:
            for v in g[node]:
                curQ.append([v, dis-1, col])
                    
for node, dis, col in Q:
    curQ = []
    curQ.append([node, dis, col])
    bfs(curQ)

for x in color:
    print(x)


### FIXED CODE ###

n, m  = map(int, input().split())
g     = {}
used  = {i:[False for _ in range(11)] for i in range(n)}
color     = [0  for _ in range(n)]

for _ in range(m):
    u, v = map(int, input().split())
    u-=1
    v-=1
    if u not in g:
        g[u] = []
    if v not in g:
        g[v] = []
    g[u].append(v)
    g[v].append(u)
    
q = int(input())
Q = []

for _ in range(q):
    node, dis, col = map(int, input().split())
    Q.append([node-1, dis, col])
Q = Q[::-1]

def bfs(now, dist, col):
    if dist < 0:
        return
    
    if used[now][dist]:
        return
 
    used[now][dist] = True
    
    if not color[now]:
        color[now] = col
 
    if now in g:
        for x in g[now]:
            bfs(x, dist - 1, col)
            
for node, dis, col in Q:
    bfs(node, dis, col)

for x in color:
    print(x)
### BUGGY CODE ###

x,y,z,k=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

AB=[0]*(x*y)
i=0
for a in A:
    for b in B:
        AB[i]=a+b
        i+=1

AB.sort(reverse=True)
ABC=[0]*(min(k,x*y)*z)
i=0
for ab in AB[:min(k,x*y)]:
    for c in C:
        ABC[i]=ab+c
        i+=1

ABC.sort(reverse=True)

for i in range(k):
    print(ABC[i])


### FIXED CODE ###

x,y,z,k=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)


AB=[a+b for a in A for b in B]
AB.sort(reverse=True)

ABC=[ab+c for ab in AB[:min(k,x*y)] for c in C]
ABC.sort(reverse=True)

for i in range(k):
    print(ABC[i])
### BUGGY CODE ###

import numpy as np
import collections
H,W=map(int,input().split())
went=[[False]*W for i in range(H)]
queue=collections.deque()
for hoge in range(H):
    for huga,t in enumerate(input()):
        if t=="#":
            went[hoge][huga]=True
            queue.append([hoge,huga,0])
while queue:
    curx,cury,ct=queue.popleft()
    for dx,dy in [[1,0],[-1,0],[0,1],[0,-1]]:
        newx,newy=curx+dx,cury+dy
        newct=ct+1
        if 0<=newx<H and 0<=newy<W and (not went[newx][newy]):
            went[newx][newy]=True
            queue.append([newx,newy,newct])
print(ct)

### FIXED CODE ###

import collections
H,W=map(int,input().split())
went=[[False]*W for i in range(H)]
queue=collections.deque()
for hoge in range(H):
    for huga,t in enumerate(input()):
        if t=="#":
            went[hoge][huga]=True
            queue.append([hoge,huga,0])
while queue:
    curx,cury,ct=queue.popleft()
    for dx,dy in [[1,0],[-1,0],[0,1],[0,-1]]:
        newx,newy=curx+dx,cury+dy
        newct=ct+1
        if 0<=newx<H and 0<=newy<W and (not went[newx][newy]):
            went[newx][newy]=True
            queue.append([newx,newy,newct])
print(ct)