Harryxun/stf_run huggingface dataset:
import numpy as np
H, W=map(int, input().split())
S=np.array([list(input()) for _ in range(H)])
INF=np.inf
#print(S)
def bfs(sx,sy,gx,gy):
  #dx, dy 四方向に対応したベクトルのリスト
  dx=[1,0,-1,0]
  dy=[0,1,0,-1]
  #P: (x, y)のキュー
  P=[]
  #d: スタートから各点までの最小距離の配列
  d=np.ones((H, W))*INF
  #スタート地点をキューに入れ、その点の距離を0にする
  P.append([sx, sy])
  d[sx,sy]=0
    
  #キューがからになるまでループ
  while len(P)>0:
    #キューの先頭を取り出す
    p=P.pop(0)
    #取り出してきた状態がゴールなら探索をやめる
    if (p[0]==gx and p[1]==gy):
      break
        
    #移動四方向をループ
    for i in range(4):
      #移動した後の点をnx, nyとする
      nx=p[0]+dx[i]
      ny=p[1]+dy[i]
            
      #移動が可能かどうかの判定とすでに訪れたことがあるかどうかの判定（d[nx, ny]!=INFならおtpずれたことがある）
      if 0<=nx and nx<H and 0<=ny and ny<W and S[nx, ny]!="#" and d[nx, ny]==INF:
        #移動できるならキューに入れ、その点の距離をpからの距離＋１で確定する
        P.append([nx, ny])
        d[nx, ny]=d[p[0], p[1]]+1
  #print(d)
  if d[gx,gy]!=INF:
    result=d[gx, gy]
  else:
    result=0
  return result
ans=0
Tlen=H*W
for i in range(Tlen):
  for j in range(i,Tlen):
    sx,sy=i%H, int(i//H)
    gx,gy=j%H, int(j//H)
    
    if S[sx,sy]=="#" or S[gx,gy]=="#":
      continue
    res=bfs(sx,sy,gx,gy)
    ans=max(ans, res)
"""
for sx in range(H):
  for sy in range(W):
    for gx in range(H):
      for gy in range(W):
        if S[sx,sy]=="#" or S[gx,gy]=="#":
          continue
        res=bfs(sx,sy,gx,gy)
        ans=max(ans, res)
"""
print(int(ans))

### FIXED CODE ###

import numpy as np
H, W=map(int, input().split())
S=np.array([list(input()) for _ in range(H)])
INF=-1
#print(S)
def bfs(sx,sy):
  #dx, dy 四方向に対応したベクトルのリスト
  dx=[1,0,-1,0]
  dy=[0,1,0,-1]
  #P: (x, y)のキュー
  P=[]
  #d: スタートから各点までの最小距離の配列
  d=np.ones((H, W))*INF
  #スタート地点をキューに入れ、その点の距離を0にする
  P.append([sx, sy])
  d[sx,sy]=0
    
  #キューがからになるまでループ
  while len(P)>0:
    #キューの先頭を取り出す
    p=P.pop(0)
    #取り出してきた状態がゴールなら探索をやめる
    """
    if (p[0]==gx and p[1]==gy):
      break
    """
        
    #移動四方向をループ
    for i in range(4):
      #移動した後の点をnx, nyとする
      nx=p[0]+dx[i]
      ny=p[1]+dy[i]
            
      #移動が可能かどうかの判定とすでに訪れたことがあるかどうかの判定（d[nx, ny]!=INFならおtpずれたことがある）
      if 0<=nx and nx<H and 0<=ny and ny<W and S[nx, ny]!="#" and d[nx, ny]==INF:
        #移動できるならキューに入れ、その点の距離をpからの距離＋１で確定する
        P.append([nx, ny])
        d[nx, ny]=d[p[0], p[1]]+1
  """
  #print(d)
  if d[gx,gy]!=INF:
    result=d[gx, gy]
  else:
    result=0
  """
  result=d.max()
  return result
ans=0
Tlen=H*W
for sx in range(H):
  for sy in range(W):
    if S[sx,sy]=="#":
      continue
    res=bfs(sx,sy)
    ans=max(ans, res)
"""
for i in range(Tlen):
  for j in range(i,Tlen):
    sx,sy=i%H, int(i//H)
    gx,gy=j%H, int(j//H)
    
    if S[sx,sy]=="#" or S[gx,gy]=="#":
      continue
    res=bfs(sx,sy,gx,gy)
    ans=max(ans, res)
"""
"""
for sx in range(H):
  for sy in range(W):
    for gx in range(H):
      for gy in range(W):
        if S[sx,sy]=="#" or S[gx,gy]=="#":
          continue
        res=bfs(sx,sy,gx,gy)
        ans=max(ans, res)
"""
print(int(ans))
While True:
    array = input().split(" ")
    a = int(array[0])
    op = array[1]
    b = int(input())

    if op == "?":
        break
    elif op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/":
        print(a / /b)
    

### FIXED CODE ###

while True:
    a, op, b = input().split(" ")
    if op == "?":
        break
    elif op == "+":
        print( int(a) + int(b) )
    elif op == "-":
        print( int(a) - int(b) )
    elif op == "*":
        print( int(a) * int(b) )
    elif op == "/":
        print( int(a) // int(b) )
# coding:utf-8
a,v = map(int,input().split())
b,w = map(int,input().split())
t = input()
 
move_a = int(v) * int(t) + int(a)
move_b = int(w) * int(t) + int(b)
 
if move_a >= move_b:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

s = input()
print(s[0] + s[1] + s[2])
a, b = map(int .input().split())
if (a*b) % 2:
  print("Odd")
else:
  print("Even")

### FIXED CODE ###

a, b = map(int, input().split())
if (a*b) % 2:
    print("Odd")
else:
    print("Even")
N,A,B,C,D = map(int, input().split())
S = [""] + list(input())

def can(start, end):
    for i in range(start, end):
        if S[i] == S[i + 1] == "#":
            return False
    return True

def main():
    if not (can(A, C) and can(B, D)):
        return False

    if C < D:
        flag = False
        for i in range(B, D + 1):
            if S[i - 1] == S[i] == S[i + 1] == ".":
                flag = True
        if not flag:
            return False
    
    return True

if __name__ == "__main__":
    if main():
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

N,A,B,C,D = map(int,input().split())
# 1-indexed
S = ["$"] + list(input())

if A < B < D < C:
    flag = False

    for i in range(B+1,D+2):
        if S[i-2] == S[i-1] == S[i] == ".":
            flag = True
            break
    for i in range(A+1,C+1):
        if S[i] == S[i-1] == "#":
            flag = False
            break
    
    if flag:
        print("Yes")
    else:
        print("No")

elif A < B < C < D:
    flag = True
    for i in range(A+1,D+1):
        if S[i] == S[i-1] == "#":
            flag = False
            break
    
    if flag:
        print("Yes")
    else:
        print("No")
        
elif A < C < B < D:
    flag = True
    for i in range(A+1,C+1):
        if S[i] == S[i-1] == "#":
            flag = False
            break
    for i in range(B+1,D+1):
        if S[i] == S[i-1] == "#":
            flag = False
            break
    if flag:
        print("Yes")
    else:
        print("No")
def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)

def lcm(l):
    def aux(l, i):
        if i == len(l) - 1:
            return l[-1]
        rest = aux(l, i+1)
        return int((l[i] * rest) / gcd(l[i], rest))
    return aux(l, 0)

def modsum(a):
    k = lcm(a) - 1
    return sum(map(lambda x: k % x, a))

if __name__ == '__main__':
    _ = input()
    a = list(map(int, input().split()))
    print(modsum(a))

### FIXED CODE ###

import sys

sys.setrecursionlimit(3100)

def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)

def lcm(l):
    def aux(l, i):
        if i == len(l) - 1:
            return l[-1]
        rest = aux(l, i+1)
        return l[i] * rest // gcd(l[i], rest)
    return aux(l, 0)

def modsum(a):
    k = lcm(a) - 1
    return sum(map(lambda x: k % x, a))

if __name__ == '__main__':
    _ = input()
    a = list(map(int, input().split()))
    print(modsum(a))
input = stdin.readline

N = int(input())

b = False
cnt = 0
for i in range(N):
    D1, D2 = map(int, input().split())
    if D1 == D2:
        cnt += 1
        if cnt == 3:
            b = True
    else:
        cnt = 0

if b == False:
    print('No')
else:
    print('Yes')

### FIXED CODE ###

from sys import stdin
input = stdin.readline

N = int(input())

b = False
cnt = 0
for i in range(N):
    D1, D2 = map(int, input().split())
    if D1 == D2:
        cnt += 1
        if cnt == 3:
            b = True
    else:
        cnt = 0

if b == True:
    print('Yes')
else:
    print('No')
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True  and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def foo(x):
    b = []
    for i in range(n):
        b.append([x for x in a[i]])
    #ddprint(b)
    cnt = 0
    rem = [False]*m
    while cnt<n:
        top = [0]*m
        ok = True
        for i in range(n):
            top[b[i][-1]] += 1
        for j in range(m):
            if top[j]>x:
                ok = False
                rem[j] = True
                cnt += 1
                if cnt==n:
                    return False
        if ok:
            return True
        for i in range(n):
            while len(b[i])>0 and rem[b[i][-1]]:
                b[i].pop()
    return True

n,m = inm()
a = []
for i in range(n):
    aa = inl()
    aa = [x-1 for x in aa]
    aa.reverse()
    a.append(aa)

ddprint(a)
mx = n
mn = 0
while mx>mn+1:
    mid = (mx+mn)//2
    if foo(mid):
        mx = mid
    else:
        mn = mid
print(mx)


### FIXED CODE ###

from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True  and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def foo(x):
    b = []
    for i in range(n):
        b.append([y for y in a[i]])
    #ddprint(b)
    cnt = 0
    rem = [False]*m
    while cnt<m:
        #ddprint("in loop x {} cnt {} b, rem".format(x,cnt))
        #ddprint(b)
        #ddprint(rem)
        top = [0]*m
        ok = True
        for i in range(n):
            top[b[i][-1]] += 1
        for j in range(m):
            if top[j]>x:
                ok = False
                rem[j] = True
                cnt += 1
                if cnt==m:
                    return False
        if ok:
            return True
        for i in range(n):
            while len(b[i])>0 and rem[b[i][-1]]:
                b[i].pop()
    return True

n,m = inm()
a = []
for i in range(n):
    aa = inl()
    aa = [x-1 for x in aa]
    aa.reverse()
    a.append(aa)

ddprint(a)
mx = n
mn = 0
while mx>mn+1:
    mid = (mx+mn)//2
    if foo(mid):
        mx = mid
    else:
        mn = mid
print(mx)
import math
while True:
    s=input().split()
    if s[0]=="?":
        break
    elif s[1]=="+":
        print(int(s[0])+int(s[2]))
    elif s[1]=="-":
        print(int(s[0])-int(s[2]))
    elif s[1]=="*":
        print(int(s[0])*int(s[2]))
    elif s[1]=="/":
        print(math.floor(int(s[0])/int(s[2])))


### FIXED CODE ###

import math
while True:
    s=input().split()
    if s[1]=="?":
        break
    elif s[1]=="+":
        print(int(s[0])+int(s[2]))
    elif s[1]=="-":
        print(int(s[0])-int(s[2]))
    elif s[1]=="*":
        print(int(s[0])*int(s[2]))
    elif s[1]=="/":
        print(math.floor(int(s[0])/int(s[2])))
while True:
    n = int(input())
    sum = int(0)
    for i in range(1,n+1):
        sum += i
    print(sum)




### FIXED CODE ###


while True:
    try:
        n = int(input())
        sum = int(0)
        for i in range(1, n+1):
            sum += i
        print(sum)
    except:
        break;
N = int(input())
P = list(map(int,input().split()))

MAP = [[min(i, j, N-i-1, N-j-1) for i in range(N)] for j in range(N)]

d = [[1 for i in range(N)] for j in range(N)]

tx = [1, 0, -1, 0]
ty = [0, 1, 0, -1]

def bfs(x, y, cnt):
    for i in range(4):
        nx = x + tx[i]
        ny = y + ty[i]
        if 0 <= nx < N and 0 <= ny < N and MAP[nx][ny] > MAP[x][y] + d[x][y]:
            MAP[nx][ny] = MAP[x][y] + d[x][y]
            bfs(nx, ny, cnt + d[x][y])

ans = 0

for p in P:
    x = (p-1) // N
    y = (p-1) % N
    d[x][y] = 0
    cnt = float('INF')
    for i in range(4):
        nx = x + tx[i]
        ny = y + ty[i]
        if 0 <= nx < N and 0 <= ny < N:
            cnt = min(cnt, MAP[nx][ny] + d[nx][ny])
        else:
            cnt = min(cnt, 0)
    
    ans += MAP[x][y]
    
    MAP[x][y] = cnt
    
    bfs(x, y, cnt)
    

print(ans)

### FIXED CODE ###

from collections import deque

N = int(input())
P = list(map(int,input().split()))

MAP = [min(i, j, N-i-1, N-j-1) for i in range(N) for j in range(N)]

d = [1] * (N ** 2)

ans = 0

def update(np, p):
    if MAP[np] > MAP[p] + d[p]:
        q.append(np)
        MAP[np] = MAP[p] + d[p]

for p in P:
    p -= 1
    
    d[p] = 0
    
    ans += MAP[p]
    
    q = deque()
    
    q.append(p)
    
    while len(q) != 0:
        p = q.popleft()
        if p % N != N-1:
            update(p+1, p)
        if p % N != 0:
            update(p-1, p)
        if p // N != N-1:
            update(p+N, p)
        if p // N != 0:
            update(p-N, p)

print(ans)
x, a, b = (int(i) for i in input().split())
if abs(x-a) < abs(x-b):
    print(A)
else:
    print(B)

### FIXED CODE ###

x, a, b = (int(i) for i in input().split())
if abs(x-a) < abs(x-b):
    print('A')
else:
    print('B')
S = input()
    if S == "Sunny":
      print("Cloudy")
    elif S == "Cloudy":
      print("Rainy")
    elif S == "Rainy":
      print("Sunny")

### FIXED CODE ###

S = input()
if S == "Sunny":
	print("Cloudy")
elif S == "Cloudy":
	print("Rainy")
elif S == "Rainy":
	print("Sunny")
n = int(input())

def p(x):
  if x == 2:
    return True
  for i in range(x/2):
    if x % i == 0:
      return False
  return True

for i in range(x,2*x):
  if p(i):
    print(i)
    break

### FIXED CODE ###

n = int(input())
 
def p(x):
  if x == 2:
    return True
  for i in range(2,x//2):
    if x % i == 0:
      return False
  return True
 
for i in range(n,2*n):
  if p(i):
    print(i)
    break
import fraction

N = (int(i) for i in input().split()) 
A = [int(i) for i in input().split()] 

A.sort()

res = A[0]
for aa in A:
    res = fraction.gcd(res, aa)

print(res)

### FIXED CODE ###

import fractions

N = (int(i) for i in input().split()) 
A = [int(i) for i in input().split()] 

A.sort()

res = A[0]
for aa in A:
    res = fractions.gcd(res, aa)

print(res)
def main():
  N = int(input())
  A = [int(x) for x in input().split()]
  
  B = [0] * N
  B = int(B)
  for i in range(N):
    e = int(A[N-i-1])
    B[e] += 1
  
  for i in range(N):
    print(B[i])
    
if __name__ == '__main__':
  main()

### FIXED CODE ###

def main():
  N = int(input())
  A = [int(x) for x in input().split()]
  
  B = [0] * N    
  for i in range(N-1):
      B[A[N-i-2]-1] += 1
  
  for i in range(N):
    print(B[i])
    
if __name__ == '__main__':
  main()
import math

r = int(input())

area = r * r * math.pi
length = r * 2 * math.pi

print(area,end=' ')
print(length)

### FIXED CODE ###

import math
r = float(input())

area = r * r * math.pi
length = r * 2 * math.pi

print("{0:.6f}".format(area),end=' ')
print("{0:.6f}".format(length))
import random
a = int(input('<< '))
k=0
g=0
for i in range(1,a):
  if i%2 == 1:
    k += 1
  v = k/a

print v
   
    

### FIXED CODE ###

a = int(input())
if a%2 == 0:
  print(1/2)
else:
  print((a//2+1)/a)
K=int(input())
S=list(input())
if len(S)<=K:
  print(S)
else:
  print(S[:K]+"...")

### FIXED CODE ###

K=int(input())
S=list(input())
if len(S)<=K:
  print("".join(S))
else:
  print("".join(S[:K])+"...")
N = int(input())

dic = dict()
dic[0] = 0
for i in range(1, N+1):
    a = bin(i)
    cnt = 0
    for j in range(2, len(a)):
        if a[j] == '1':
            cnt += 1
    b = i%cnt
    if i not in dic:
        dic[i] = b

X = input()
X = int('0b' + X, 0)
res = 1 << N-1
for i in range(N):
    now = X ^ res
    #print(now, res)
        
    a = bin(now)
    #print(a)
    cnt = 0
    for j in range(2, len(a)):
        if a[j] == '1':
            cnt += 1
    b = now%cnt
    #print(now, cnt, b)
    ans = 1
    while b > 0:
        b = dic[b]
        ans += 1
    print(ans)
    
    res = res >> 1

### FIXED CODE ###

N = int(input())
X = input()

arr = [0 for _ in range(N+1)]
for i in range(1, N+1):
    cnt = bin(i).count('1')
    arr[i] = arr[i%cnt] + 1

x = int(X, 2)
pop = X.count('1')
plu = x % (pop+1)
mai = x % (pop-1) if pop>1 else 0

#bi = 1 << N
for i in range(N):
    #bi = bi >> 1
    if X[i] == '0':
        #res = (plu + bi % (pop+1)) % (pop+1)
        res = (plu + pow(2, N-1-i, pop+1)) % (pop+1)
    else:
        if pop == 1:
            print(0)
            continue
        #res = (mai - bi % (pop-1)) % (pop-1)
        res = (mai - pow(2, N-1-i, pop-1)) % (pop-1)
    print(arr[res] + 1)
import sys
input=lambda: sys.stdin.readline().rstrip()
import heapq
n,m,s=map(int,input().split())
E=[]
for _ in range(m):
  E.append(tuple(map(int,input().split())))
CD=[]
for _ in range(n):
  CD.append(tuple(map(int,input().split())))
nn=n*2500
edge=[[] for i in range(nn)]
for u,v,a,b in E:
  u-=1
  v-=1
  for i in range(a,2500):
    edge[u*2500+i].append(b*10**6+v*2500+i-a)
    edge[v*2500+i].append(b*10**6+u*2500+i-a)
for i in range(n):
  c,d=CD[i]
  for j in range(2500):
    if j+c<2500:
      edge[i*2500+j].append(d*10**6+i*2500+j+c)

def dijkstra_heap(s):
  d=[float("inf")]*nn
  used=[True]*nn
  d[s]=0
  used[s]=False
  edgelist=[]
  for e in edge[s]:
    heapq.heappush(edgelist,e)
  while edgelist:
    minedge=heapq.heappop(edgelist)
    minedge_cost=minedge//(10**6)
    minedge_v=minedge%(10**6)
    if not used[minedge_v]:
      continue
    d[minedge_v] = minedge_cost
    used[minedge_v] = False
    for e in edge[minedge_v]:
      e_cost=e//(10**6)
      e_v=e%(10**6)
      if used[e_v]:
        heapq.heappush(edgelist,e+minedge_cost*10**6)
  return d
D=dijkstra_heap(s)
for i in range(1,n):
  ans=D[i*2500]
  for j in range(1,2500):
    ans=min(ans,D[i*2500+j])
  print(ans)


### FIXED CODE ###

import sys
input=lambda: sys.stdin.readline().rstrip()
import heapq
n,m,s=map(int,input().split())
s=min(s,2499)
E=[]
for _ in range(m):
  E.append(tuple(map(int,input().split())))
CD=[]
for _ in range(n):
  CD.append(tuple(map(int,input().split())))
nn=n*2500
edge=[[] for i in range(nn)]
for u,v,a,b in E:
  u-=1
  v-=1
  for i in range(a,2500):
    edge[u*2500+i].append(b*10**6+v*2500+i-a)
    edge[v*2500+i].append(b*10**6+u*2500+i-a)
for i in range(n):
  c,d=CD[i]
  for j in range(2500):
    if j+c<2500:
      edge[i*2500+j].append(d*10**6+i*2500+j+c)

def dijkstra_heap(s):
  d=[float("inf")]*nn
  used=[True]*nn
  d[s]=0
  used[s]=False
  edgelist=[]
  for e in edge[s]:
    heapq.heappush(edgelist,e)
  while edgelist:
    minedge=heapq.heappop(edgelist)
    minedge_cost=minedge//(10**6)
    minedge_v=minedge%(10**6)
    if not used[minedge_v]:
      continue
    d[minedge_v] = minedge_cost
    used[minedge_v] = False
    for e in edge[minedge_v]:
      e_cost=e//(10**6)
      e_v=e%(10**6)
      if used[e_v]:
        heapq.heappush(edgelist,e+minedge_cost*10**6)
  return d
D=dijkstra_heap(s)
for i in range(1,n):
  ans=D[i*2500]
  for j in range(1,2500):
    ans=min(ans,D[i*2500+j])
  print(ans)
r=int(input())
return(3*r*r)

### FIXED CODE ###

r=int(input())
print(3*r*r)
a,b,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
cheap = min(a) + min(b)
for _ in range(m):
  x,y,c = map(int,input().split())
  cheap = min(a[x-1]+b[x-1]-c,cheap)
print(cheap)

### FIXED CODE ###

A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
z = [list(map(int, input().split())) for i in range(M)]

price = min(a) + min(b)

for e in z:
    tmp_price = a[e[0]-1] + b[e[1]-1] - e[2]

    if(price > tmp_price):
        price = tmp_price

print(price)
import numpy as np
#from numba import njit

#(N, K) = map(int, input().split())
#A = np.array(list(map(int, input().split())))
N = int(input())
h = np.array(list(map(int, input().split())))

#@njit
def solve(N,h,s):
    if (np.all(h <= 0)):
        return s
    else:
        w = np.where(h > 0)[0]
        try:
            l = w[0]
            r = w[0]
        except Exception as e:
            return s
        i = 1
        while (i < len(w)):
            if (w[i] == r + 1):
                r = w[i]
            i += 1
        cat = np.concatenate([h[:l], h[l:r+1]-1, h[r+1:]])
        return solve(N, cat, s+1)

print(solve(N,h,0))


### FIXED CODE ###

import numpy as np
#from numba import njit

#(N, K) = map(int, input().split())
#A = np.array(list(map(int, input().split())))
N = int(input())
h = np.array(list(map(int, input().split())))

#@njit

def solve(N,h):
    s = 0
    while (np.any(h > 0)):
        w = np.where(h > 0)[0]
        l = w[0]
        r = w[0]
        i = 1
        while (i < len(w)):
            if (w[i] == r + 1):
                r = w[i]
            i += 1
        
        h = np.concatenate([h[:l], h[l:r+1]-1, h[r+1:]])
        s += 1
    return s

print(solve(N,h))
def main():
    import sys
    import numpy as np
    ikimasu = sys.stdin.buffer.readline
    ini = lambda: int(ins())
    ina = lambda: list(map(int, ikimasu().split()))
    ins = lambda: ikimasu().strip()
    n,k = ina()
    tmp = [[] for _ in range(n)]
    for _ in range(n-1):
        x,x1=  ina()
        x-=1
        x1-=1
        tmp[x].append(x1)
        tmp[x1].append()
    def dfs(teiru,ta):
        rick = 1
        coulduse = k-1 if ta==-1 else k-2
        if(coulduse<len(tmp[teiru])):
            return 0
        for i in tmp[teiru]:
            if i == ta:
                continue
            rick*=coulduse
            rick%=1000000007
            coulduse-=1
            rick*=dfs(i,teiru) 
            rick%=1000000007
        return rick
    print(k,dfs(0,-1))
    print(k*dfs(0,-1)%1000000007)
    

    


        
        
        


    
        


        


    




















if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    import sys
    sys.setrecursionlimit(311111)
    import numpy as np
    ikimasu = sys.stdin.buffer.readline
    ini = lambda: int(ins())
    ina = lambda: list(map(int, ikimasu().split()))
    ins = lambda: ikimasu().strip()
    n,k = ina()
    tmp = [[] for _ in range(n)]
    for _ in range(n-1):
        x,x1=  ina()
        x-=1
        x1-=1
        tmp[x].append(x1)
        tmp[x1].append(x)
    def dfs(teiru,ta):
        rick = 1
        coulduse = k-1 if ta==-1 else k-2
        for i in tmp[teiru]:
            if i == ta:
                continue
            rick*=coulduse
            rick%=1000000007
            coulduse-=1
            rick*=dfs(i,teiru) 
            rick%=1000000007
        return rick
    print(k*dfs(0,-1)%1000000007)
    

    


        
        
        


    
        


        


    




















if __name__ == "__main__":
    main()
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(' ')))
taste = []
for i in range(x - 8 if x - 8 < 0 else 0, x):
    for j in range(y - 8 if x - 8 < 0 else 0, y):
        for l in range(z - 8 if x - 8 < 0 else 0, z):
            taste.append(a[i] + b[j] + c[l])
taste.sort()
for i in range(k):
    print(taste[-1-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)
ans=[]
for i in range(x):
  for j in range(y):
    for k in range(z):
      if (i+1)*(j+1)*(k+1)<=K:
        ans.append(a[i]+b[j]+c[k])
      else:
        break
ans.sort(reverse=True)
for i in range(K):
  print(ans[i])