Harryxun/stf_run huggingface dataset:
n,m=map(int,input().split())
r=list(map(int,input().split()))
c=list(map(int,input().split()))
r.sort(reverse=True)
c.sort(reverse=True)
dict1={}
dict2={}
for i in range(n):
    dict1.setdefault(r[i],0)
    dict1[r[i]]+=1
for i in range(m):
    dict2.setdefault(c[i],0)
    dict2[c[i]]+=1
x,y=0,0
ans=1
if dict1.get(n*m)*dict2.get(n*m)>1:
    print(0)
    exit()
for i in range(n*m,0,-1):
    table=x*y
    ex=table-(n*m-i)
    dy=dict1.get(i,0)
    dx=dict2.get(i,0)
    x+=dx
    y+=dy
    if dx*dy==1:
        ans*=1
    elif dx==0 and dy==1:
        ans*=x
    elif dy==0 and dx==1:
        ans*=y
    else:
        ans*=(x*y-(n*m-i))
print(ans%(10**9+7))

### FIXED CODE ###

n,m=map(int,input().split())
r=list(map(int,input().split()))
c=list(map(int,input().split()))
r.sort(reverse=True)
c.sort(reverse=True)
dict1={}
dict2={}
for i in range(n):
    dict1.setdefault(r[i],0)
    dict1[r[i]]+=1
for i in range(m):
    dict2.setdefault(c[i],0)
    dict2[c[i]]+=1
x,y=0,0
ans=1
mod=10**9+7
for i in range(n*m,0,-1):
    dy=dict1.get(i,0)
    dx=dict2.get(i,0)
    if dx*dy==1:
        x+=1
        y+=1
    elif dx==0 and dy==1:
        ans*=x
        y+=1
    elif dy==0 and dx==1:
        ans*=y
        x+=1
    else:
        ans*=(x*y-(n*m-i))
        ans%=mod
print(ans%mod)
s = int(input())
t = int(input())
cnt = 0
for i, a in enumerate(s):
  if t[i] == a:
    cnt += 1

print(cnt)

### FIXED CODE ###

pred = [i for i in input()]
data = [i for i in input()]
cnt = 0

for i in range(3):
  if pred[i] == data[i]:
    cnt += 1

print(cnt)
(n, m) = [int(i) for i in input().split()]
A = []
b = []
for i in range(n):
A.append([int(j) for j in input().split()])

for i in range(m):
b.append(int(input()))

for i in range(n):
    s = 0
for j in range(m):
    s += A[i][j] * b[j]
print(s)

### FIXED CODE ###

(n, m) = [int(i) for i in input().split()]
A = []
b = []
for i in range(n):
    A.append([int(j) for j in input().split()])

for i in range(m):
    b.append(int(input()))

for i in range(n):
    s = 0
    for j in range(m):
        s += A[i][j] * b[j]
    print(s)
a,b,t = map(int, input().split())
ans = ((T+0.5) // a)*b
print(int(ans))

### FIXED CODE ###

a,b,t = map(int, input().split())
ans = ((t+0.5) // a)*b
print(int(ans))
while True:
	h, w = map(int, raw_input().split())
	if h + w == 0: break
	b = [list(raw_input()) for i in range(h)]
	direction = {'>':[1,0],'v':[0,1],'<':[-1,0],'^':[0,-1]}
	f = False
	for i in range(h):
		for j in range(w):
			if b[j][i] != ".":
				p = [i,j]
				f = True
				break
		if f: break
	c = 0
	while True:
		tmp = direction[b[p[1]][p[0]]]
		p[0] += tmp[0]
		p[1] += tmp[1]
		c += 1
		if c == h * w:
			print "LOOP"
			break
		elif b[p[1]][p[0]] == ".":
			print "{} {}".format(p[0],p[1])
			break

### FIXED CODE ###

while True:
	h, w = map(int, raw_input().split())
	if h + w == 0: break
	b = [list(raw_input()) for i in range(h)]
	x = y = 0
	while True:
		a = b[y][x]
		b[y][x] = 0
		if a == ">": x += 1
		elif a == "<": x -= 1
		elif a == "v": y += 1
		elif a == "^": y -= 1
		elif a == ".": print x,y; break
		else: print "LOOP"; break
from collections import deque

def bfs(maze, visited, sy, sx, dead, goal):
    queue = deque([[sy, sx]])
    visited[sy][sx] = 0
    count = 0
    while queue:
        y, x = queue.popleft()
        if maze[y][x] == goal:
            count += 1
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            new_y, new_x = y+j, x+k
            if not maze[new_y][new_x] in dead and \
                visited[new_y][new_x] == -1:
                visited[new_y][new_x] = visited[y][x] + 1
                queue.append([new_y, new_x])
    return count % 1000000007
if __name__ == "__main__":
    n,m=map(int, input().split())
    a=[int(input()) for i in range(m)]
    maze=[[2*i+j for i in range(int(n/2+1))] for j in range(n+1)]
    visited = [[[-1] for i in range(int(n/2+1))] for j in range(n+1)]
    print(bfs(maze, visited, 0, 0, a, n))


### FIXED CODE ###

N, M=map(int, input().split())
items=[int(input()) for i in range(M)]
mod=10**9+7
dp=[0 for i in range(N+1)]
dp[0] = 1
is_broken =[1 for i in range(N+1)]

for i in range(M):
    is_broken[items[i]] = 0

for i in range(N):
    if i-1 >= 0:
        dp[i+1] = dp[i]*is_broken[i] + dp[i-1]*is_broken[i-1]
    else:
        dp[i+1] = dp[i]*is_broken[i]
    dp[i+1] %= mod

print(dp[N])
S=input('S')
if S='ABC':
  print('ARC')
else:
  print('ABC')

### FIXED CODE ###

S=input()
if 'B' in S:
  print('ARC')
else:
  print('ABC')
# -*- coding: utf-8 -*-
n = int(input())
n = str(n)
if len(p) => 3:
    p = n[-3]+n[-2]+n[-1]
if len(p) == 2:
    p = n[-2]+n[-1]
if len(p) == 1:
    p = n[-1]
print(int(p))

### FIXED CODE ###

# -*- coding: utf-8 -*-
n = int(input())
a = 1000-n%1000
if a != 1000:
    print(a)
else:
    print(0)
cnt = 0
def s(start, end):
    global cnt
    if(start==len(S)-1):
        return 
        
    numS = int(S[start:end+1])
    if(numS%2019==0 and numS!=0):
        cnt += 1
    if(end==len(S)-1):
        end = start+1
        s(start+1, end)
        return
    s(start, end+1)

S = input()
s(0, 0)
print(cnt)

### FIXED CODE ###

S = list(map(int, list(input())))[::-1]
N = len(S)
CNT = [0]*2019
CNT[0] = 1
num = 0
d = 0
for i in range(N):
    num += S[i]*pow(10, d, 2019)
    num %= 2019
    CNT[num] += 1
    d += 1
ans = 0 
for cnt in CNT:
    ans += (cnt*(cnt - 1)) // 2
print(ans)
a,b,n=map(int(input()split()))
print(max(a-n,0),max(b-max(a-n,0),0))

### FIXED CODE ###

a,b,n=map(int,input().split())  
print(max(a-n,0),max(b-max(n-a,0),0))
N = int(input())
ret = 1 - 1 + N - 1
for div in range(2, int(N ** 0.5) + 1):
    if N % div != 0: continue
    ret = min(ret, div - 1 + N // div - 1)
print(ret)

### FIXED CODE ###

import math

a, b, x = map(int, input().split())
ret = (b - x / a**2) * 2 / a if a**2 * b <= 2 * x else  a * b**2 / (2 * x)
print(math.degrees(math.atan(ret)))
s = input()

if 'hi' in s:
  return 'Yes'
else:
  return 'No'

### FIXED CODE ###

s = input()

if s == 'hi':
  print('Yes')
elif s == 'hihi':
  print('Yes')
elif s == 'hihihi':
  print('Yes')
elif s == 'hihihihi':
  print('Yes')
elif s == 'hihihihihi':
  print('Yes')
else:
  print('No')
def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
 
n = int(input())
A = [int(input()) for i in range(n)]
 
cnt = 0
G = [1]
for i in range(99):
    if n < 1 + 3*G[-1]:
        break
    G.append(1 + 3*G[-1])
m = len(G)
G.reverse()
for i in range(m):
    insertionSort(A, n, G[i])
 
print(m)
print(*G)
print(cnt)
print(*A, sep='\n')


### FIXED CODE ###

import sys


def print_A(A):
    for i in range(len(A)):
        sys.stdout.write(str(A[i]))
        if i!= len(A) -1:
            sys.stdout.write(' ')
    print()


def insertionSort(A,n,g):
    cnt = 0
    for i in range(g,n):
        v = A[i]
        j = i - g
        while (j>=0) and (A[j] > v):
            A[j + g] = A[j]
            j -= g
            cnt +=1
        A[j + g] = v
    return cnt

def shellSort(A,n,G):
    cnt = 0
    for i in range(len(G)):
        cnt += insertionSort(A,n,G[i])
    return cnt
        

def get_gap(n):
    G = []
    h = 1
    cnt = 1
    while h <= n:
        G.append(h)
        h = 3*h + 1
        cnt +=1
    if len(G) == 0: G.append(1)
    return list(reversed(G))


n = int(input())
A = [0] * n
for i in range(n):
    A[i] = int(input())
    
G = get_gap(n)
m = len(G)
cnt = shellSort(A,n,G)

print(m)
print_A(G)
print(cnt)
for i in range(n):
    print(A[i])
# import syinput = sys.stdin.readline
md = 1000000007
dp=[]
def countways(n,broken,ix):
	global dp,md
	if(dp[ix]!=-1):
		return dp[ix]

	ways = 0
	if((ix+1)<=n and broken[ix+1]==0):
		ways+=countways(n,broken,ix+1)
	if((ix+2)<=n and broken[ix+2]==0):
		ways+=countways(n,broken,ix+2)
	dp[ix]=(ways%md)
	return dp[ix]

n,m = list(map(int,input().split()))
dp = [-1 for i in range(n+1)]
dp[n] = 1
broken = [0 for i in range(n+1)]
for i in range(m):
	broken[int(input())]=1
# print(brok	en)
print(countways(n,broken,0)%md)

### FIXED CODE ###

md = 1000000007
n,m = list(map(int,input().split()))
broken = [0 for i in range(n+1)]
dp=[0 for i in range(n+1)]
dp[0] = 1
for i in range(m):
	broken[int(input())]=1
# print(brok	en)
for j in range(1,n+1):
	if(broken[n-j]==1):
		continue
	if(j==1):
		dp[j]=1
	else:
		dp[j]=(dp[j-1]+dp[j-2])%md
# print(dp)
print(dp[n]%md)
n = int(input())
l = list(map(int, input().split()))
t = 0

for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            sum = l[i] + l[j] + l[k]
            if sum - max(l[i], l[j], l[k]) > max(l[i], l[j], l[k]):
                if l[i] != l[j] and l[i] != l[k] and l[j] != l[k]:
                    t += 1

print(t)


### FIXED CODE ###

s = input()
d = 0

if s == "RRR":
    d = 3
elif s in {"RRS", "SRR"}:
    d = 2
elif s in {"RSR", "RSS", "SSR", "SRS"}:
    d = 1
else:
    d = 0

print(d)
h,w=map(int,input().split())
div,mod=divmod(h*w)
print(div+mod)

### FIXED CODE ###

h,w=map(int,input().split())
if h == 1 or w == 1:
  print(1)
else:
  div,mod=divmod(h*w,2)
  print(div+mod)
n,m=map(int,input().split())
ab = []
for _ in range(n):
  a,b=map(int,input().split())
  a,b=a-1,b-1
  ab.append({a,b})
import itertools

cnt = 0
for v in itertools.permutations(range(1,n)):
  l = 0
  ok = True
  for v2 in v:
    if {l,v2} not in ab:
      ok = False
      break
    l = v2
  if ok == True:
    cnt += 1
  
print(cnt)

### FIXED CODE ###

n,m=map(int,input().split())
ab = []
for _ in range(m):
  a,b=map(int,input().split())
  a,b=a-1,b-1
  ab.append({a,b})
import itertools

cnt = 0
for v in itertools.permutations(range(1,n)):
  l = 0
  ok = True
  for v2 in v:
    if {l,v2} not in ab:
      ok = False
      break
    l = v2
  if ok:
    #print(v)
    cnt += 1
  
print(cnt)
INF=1000000000000000 # 1e15
MAX=50*50 # 2500

n,m,s=map(int,input().split())
u,v,a,b,c,d=[0]*m,[0]*m,[0]*m,[0]*m,[0]*n,[0]*n
for i in range(m):
  u[i],v[i],a[i],b[i]=map(int,input().split())
  u[i] -= 1
  v[i] -= 1
for i in range(n):
  c[i],d[i]=map(int,input().split())

dp=[[INF] * (MAX + 1) for _ in range(n)]
#dp[i][j]=k <=> 最短k分後に街iに所持銀貨j枚で行ける
dp[0][s] = 0
for _ in range(n * n):
  for i in range(n):
    for j in range(MAX + 1):
      dest = min(MAX, j + c[i])
      dp[i][dest] = min(dp[i][dest], dp[i][j] + d[i])
  for i in range(m):
    for j in range(a[i], MAX+1):
      # u[i] -> v[i]
      dp[v[i]][j - a[i]] = min(dp[v[i]][j - a[i]], dp[u[i]][j] + b[i])
      # v[i] -> u[i]
      dp[u[i]][j - a[i]] = min(dp[u[i]][j - a[i]], dp[v[i]][j] + b[i])
for i in range(1, n):
  print(min(dp[i]))


### FIXED CODE ###

INF=1000000000000000 # 1e15
MAX=50*50 # 2500

n,m,s=map(int,input().split())
u,v,a,b,c,d=[0]*m,[0]*m,[0]*m,[0]*m,[0]*n,[0]*n
for i in range(m):
  u[i],v[i],a[i],b[i]=map(int,input().split())
  u[i] -= 1
  v[i] -= 1
for i in range(n):
  c[i],d[i]=map(int,input().split())

dp=[[INF] * (MAX + 1) for _ in range(n)]
#dp[i][j]=k <=> 最短k分後に街iに所持銀貨j枚で行ける
dp[0][min(MAX, s)] = 0
updated = True
while updated:
  updated = False
  for i in range(n):
    for j in range(MAX + 1):
      dest = min(MAX, j + c[i])
      if dp[i][j] + d[i] < dp[i][dest]:
        updated = True
        dp[i][dest] = dp[i][j] + d[i]
  for i in range(m):
    for j in range(a[i], MAX+1):
      # u[i] -> v[i]
      if dp[u[i]][j] + b[i] < dp[v[i]][j - a[i]]:
        updated = True
        dp[v[i]][j - a[i]] = dp[u[i]][j] + b[i]
      # v[i] -> u[i]
      if dp[v[i]][j] + b[i] < dp[u[i]][j - a[i]]:
        updated = True
        dp[u[i]][j - a[i]] = dp[v[i]][j] + b[i]
for i in range(1, n):
  print(min(dp[i]))
n=int(input())
arr=list(map(int,input().split()))
ans=0
for i in range(1,n):
	if(arr[i]<arr[i-1]):
		ans+=arr[i-1]-arr[i]
		arr[i]+=arr[i-1]-arr[i]
		
print(ans)
	


### FIXED CODE ###

n,x,t=map(int,input().split())
ans=0;
while(n>0):
	ans+=t;
	n-=x;
print(ans)
def popcount(x):
    xb = bin(x)
    return xb.count("1")
def solve(x, count_1):
    temp = x %count_1
    if(temp == 0):
        return 1
    else:
        return 1 + solve(temp, popcount(temp))
n = int(input())
x = input()
x_b = int(x, 2)
mod = x.count("1")
xm1 = x_b %(mod+1) 
xm2 = x_b %(mod-1)
for i in range(n):
    if(x[i] == "0"):
        mi = (((pow(2, n-1-i, mod+1) + xm1) % (mod+1)))
        if(mi == 0):
            print(1)
        else:
            print(1 + solve(mi, popcount(mi)))
    else:
        mi = ((xm2-pow(2, n-1-i, mod-1)) % (mod-1))
        if((x_b - xm2 == 0)):
            print(0)
        elif(mi == 0):
            print(1)
        else:
            print(1 + solve(mi, popcount(mi)))
        

### FIXED CODE ###

def popcount(x):
    xb = bin(x)
    return xb.count("1")
def solve(x, count_1):
    temp = x %count_1
    if(temp == 0):
        return 1
    else:
        return 1 + solve(temp, popcount(temp))
n = int(input())
x = input()
x_b = int(x, 2)
mod = x.count("1")
xm1 = x_b %(mod+1)
if(mod != 1):
    xm2 = x_b %(mod-1)
for i in range(n):
    if(x[i] == "0"):
        mi = (((pow(2, n-1-i, mod+1) + xm1) % (mod+1)))
        if(mi == 0):
            print(1)
        else:
            print(1 + solve(mi, popcount(mi)))
    else:
        if(mod == 1):
            print(0)
        else:
            mi = ((xm2-pow(2, n-1-i, mod-1)) % (mod-1))
            if((x_b - xm2 == 0)):
                print(0)
            elif(mi == 0):
                print(1)
            else:
                print(1 + solve(mi, popcount(mi)))
n,k = map(int,input().split())
p = list(int,input())
p.sort()
print(sum(p[:k])


### FIXED CODE ###

n, k = map(int,input().split())
p = list(map(int, input().split()))
p.sort()
print(sum(p[:k]))
n, q = map(int, input().split())
edges = [[] for _ in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)

counter = [0]*n
for i in range(q):
    p, x = map(int, input().split())
    counter[p-1] = x

visited = [0]*n


def dfs(parent):
    visited[parent] = 1
    for child in edges[parent]:
        if visited[child] == 1:
            continue
        else:
            counter[child] += counter[parent]
            dfs(child)


dfs(0)
print(*counter)

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000000)
n, q = map(int, input().split())
edges = [[] for _ in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)

counter = [0]*n
for i in range(q):
    p, x = map(int, input().split())
    counter[p-1] += x
visited = [0]*n


def dfs(parent):
    visited[parent] = 1
    for c in edges[parent]:
        if visited[c] == 1:
            continue
        else:
            counter[c] += counter[parent]
            dfs(c)


dfs(0)
print(*counter)
n = int(raw_input())
S = map(int,raw_input().split())
q = int(raw_input())
T = map(int,raw_input().split())
ans = 0
for i in q:
	if int(i) in n:
		ans += 1
print ans

### FIXED CODE ###

n = int(raw_input())
S = map(int,raw_input().split())
q = int(raw_input())
T = map(int,raw_input().split())
ans = 0
for i in T:
	if i in S:
		ans += 1
print ans
n=input()
a=0
for i in range(1,n+1):
  a=a+1
print(a)

### FIXED CODE ###

n=input()
n=int(n)
a=0
for i in range(1,n+1):
    a=a+i
print(a)
a, b, c, d, e, f = map(int, input().split())
limit = 100 * e / (100 + e)
mx = -1

waters = set()
for i in range(0, f // a + 1, 100 * a):
    for j in range(0, (f - i * a) // b + 1, 100 * b):
        waters.add(i + j)

sugars = set()
for i in range(0, f // c + 1, c):
    for j in range(0, (f - c) // d + 1, d):
        sugars.add(i + j)

for i in waters:
    for j in sugars:
        if i + j > f or i + j == 0:
            break
        noudo = (100 * j / (i + j))
        if noudo <= limit:
            if noudo > mx:
                mx = noudo
                x, y = i + j, j
print(x, y)

### FIXED CODE ###

a, b, c, d, e, f = map(int, input().split())
a, b = 100 * a, 100 * b
limit = 100 * e / (100 + e)
mx = -1

for i in range(f // a + 1):
    for j in range((f - i * a) // b + 1):
        for k in range((f - i * a - j * b) // c + 1):
            for l in range((f - i * a - j * b - k * c) // d + 1):
                water = i * a + j * b + k * c + l * d
                sugar = k * c + l * d
                if water > f or water == 0:
                    break
                if (100 * sugar / water) <= limit:
                    if (100 * sugar / water) > mx:
                        mx = (100 * sugar / water)
                        x, y = water, sugar
print(x, y)
import sys
sys.setrecursionlimit(10 ** 9)

n = int(input())
LR = [tuple(map(int, input().split())) for _ in range(n)]

def quicksort(x):
    if x==[]: return []

    smallerSorted = quicksort([a for a in x[1:] if (a[0] < x[0][0] or (a[0] == x[0][0] and a[1] >= x[0][1])])
    biggerSorted = quicksort([a for a in x[1:] if (a[0] > x[0][0] or (a[0] == x[0][0] and a[1] < x[0][1]))])

    return(smallerSorted+[x[0]]+biggerSorted)

LR = quicksort(LR)

ans = [0] * (n+1)
temp = 10 ** 9
i = 1
for L, R in LR:
    temp = min(temp, R)
    if L > temp:
        break
    ans[i] = temp - L + 1
    i += 1
#print(ans)
temp = 10 ** 9
i = n - 1
L = LR[-1][0]
for x, R in reversed(LR):
    temp = min(temp, R)
    if L > temp:
        break
    ans[i] += temp - L + 1
    i -= 1

print(max(ans))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 9)

n = int(input())
LR = [tuple(map(int, input().split())) for _ in range(n)]

def quicksort(x):
    if x==[]: return []

    smallerSorted = quicksort([a for a in x[1:] if a[0] < x[0][0] or (a[0] == x[0][0] and a[1] >= x[0][1])])
    biggerSorted = quicksort([a for a in x[1:] if a[0] > x[0][0] or (a[0] == x[0][0] and a[1] < x[0][1])])

    return(smallerSorted+[x[0]]+biggerSorted)

LR = quicksort(LR)

e = [[] for _ in range(n+2)]

ans = [0] * (n+1)
temp = 10 ** 9
i = 1
for L, R in LR:
    temp = min(temp, R)
    if L > temp:
        break
    ans[i] = temp - L + 1
    i += 1

temp = 10 ** 9
i = n - 1
L = LR[-1][0]
for x, R in reversed(LR):
    temp = min(temp, R)
    if L > temp:
        break
    ans[i] += temp - L + 1
    i -= 1

res = max(ans)
for L, R in LR:
    res = max(res, R - L + 1 + ans[0])

#print(LR)
#print(ans)
print(res)
n = input()
d = map(int, input().split())
sum = 0
for i in range(n-1):
  for j in range(i+1, n):
    sum += ij
print(sum)

### FIXED CODE ###

n = int(input())
d = list(map(int, input().split()))
sum = 0
for i in range(n-1):
  for j in range(i+1, n):
    sum += d[i] * d[j]
print(sum)
import fractions

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

C = fractions.gcd(A, B)

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b += 1
    if n > 1:
        fct.append(n)
    return act

print(len(list(set(factorize(C)))) + 1)

### FIXED CODE ###

import fractions

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

C = fractions.gcd(A, B)

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b += 1
    if n > 1:
        fct.append(n)
    return fct

print(len(list(set(factorize(C)))) + 1)
k = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
z = [int(i) for i in input().split()]

x.sort(reverse=True)
if len(x)>k[3]:
  x = x[0:k[3]]

y.sort(reverse=True)
if len(y)>k[3]:
  y = y[0:k[3]]

z.sort(reverse=True)
if len(z)>k[3]:
  z = z[0:k[3]]

e = []

for i in x:
  for j in y:
    e.append(i+j)

g = []
for i in range(k[3]):
  g.append(e[i])

f = []

for i in g:
  for j in z:
    f.append(i+j)

f.sort(reverse=True)

for i in range(k[3]):
  print(f[i])


### FIXED CODE ###

X,Y,Z,K=map(int,input().split())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
C=[int(i) for i in input().split()]
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
SUM=[]
for i in range(X):
  for j in range(Y):
    for k in range(Z):
      if (i+1)*(j+1)*(k+1)<=K:
        SUM.append(A[i]+B[j]+C[k])
      else:
        break
SUM.sort(reverse=True)
for i in range(K):
  print(SUM[i])
# D
H, W, N = map(int,input().split())
field_dict = dict()
X_list = [0]*N
Y_list = [0]*N

for i in range(N):
    X, Y = map(int,input().split())
    X_list[i] = X-1
    Y_list[i] = Y-1
    field_dict[(X-1)*1000000 + (Y-1)] = 1

def query(posi_x, posi_y):
    return field_dict.get(posi_x*1000000+posi_y, 0)

# minimam x reachable
reach_y = [W]*H
reach_y[0] = 0
posi_x, posi_y = 0, 0

while posi_x < W - 1:
    # takahashi
    if query(posi_x+1, posi_y) == 1:
        # gameover
        break
    else:
        posi_x += 1
    # aoki
    if query(posi_x, posi_y+1) == 0 and posi_y + 1 < H:
        # move
        posi_y += 1
        reach_y[posi_y] = posi_x
        
res = W

for i in range(N):
    if reach_y[Y_list[i]] < X_list[i]:
        res = min(res, X_list[i])
        
print(res)

### FIXED CODE ###

# D
H, W, N = map(int,input().split())
field_dict = dict()
X_list = [0]*N
Y_list = [0]*N

for i in range(N):
    X, Y = map(int,input().split())
    X_list[i] = X-1
    Y_list[i] = Y-1
    field_dict[(X-1)*1000000 + (Y-1)] = 1

def query(posi_x, posi_y):
    return field_dict.get(posi_x*1000000+posi_y, 0)

# minimam x reachable
reach_y = [H]*W
reach_y[0] = 0
posi_x, posi_y = 0, 0

while posi_x < H - 1:
    # takahashi
    if query(posi_x+1, posi_y) == 1:
        # gameover
        break
    else:
        posi_x += 1
    # aoki
    if query(posi_x, posi_y+1) == 0 and posi_y + 1 < W:
        # move
        posi_y += 1
        reach_y[posi_y] = posi_x
        
res = H

for i in range(N):
    if reach_y[Y_list[i]] < X_list[i]:
        res = min(res, X_list[i])
        
print(res)
x,a,b=map(int,input().split())
if b>a and b-a<x:
	print("safe")
elif b=a and b-a=x:
	print("delicious")
elif b<a and a-b<x:
	print("delicious")
else:
	print("dangerous")
	


### FIXED CODE ###

x,a,b=map(int,input().split())
if b>a and b-a<=x:
	print("safe")
elif b<=a and a-b<=x:
	print("delicious")
else:
	print("dangerous")
n,m = map(int,input().split())
a=[list(map(int, input().split())) for i in range(n)]
b=[[0]* n for j in range(n)] 
bb=[]
for i in range(n-1):
    bb.append(i)
c=[]
d=[0]*n-1
for i in range(n):
    for j in range(n):
        b[a[i][0][a[i][1]] = a[i][1]
        b[a[i][1]][a[i][0]] = a[i][0]
while len(bb)!=0:
    for i in range(n):
        if b[i][j]=-1:
            c.append(b[i][j])
            bb.deque(b[i][j])
            d[b[i][j]]=i+1
            print(b[i][j]+1)

### FIXED CODE ###

from collections import deque
n,m = map(int,input().split())
a=[list(map(int, input().split())) for i in range(m)]
b=[[] for j in range(n)] 

michi=[-1]*(n)
michi[0]=0
heya=[]


for i in range(m):
    b[a[i][0]-1].append(a[i][1])
    b[a[i][1]-1].append(a[i][0])



heya.append(1)


while len(heya):
    now=heya.pop(0)-1
    
    for i in range(len(b[now])):
        if michi[b[now][i]-1] == -1:
            heya.append(b[now][i])
            michi[b[now][i]-1] = now+1
print("Yes")
for i in range(1,n):
    print(michi[i])
import math

S=int(input())

if S==0:
    ans=[0,0,0,0,0,0]
elif S==10**18:
    ans==[0,0,10**9,0,10**9,10**9]
else:
    ans=[0,0,10**9,1]
    ans.append(10**9-S%(10**9))
    ans.append(math.ceil(S/(10**9)))
print(*ans)

### FIXED CODE ###

import math

S=int(input())

if S==0:
    ans=[0,0,0,0,0,0]
elif S==10**18:
    ans=[0,0,10**9,0,10**9,10**9]
elif S%(10**9)==0:
    ans=[0,0,10**9,0,0]
    ans.append(S//(10**9))
else:
    ans=[0,0,10**9,1]
    ans.append(10**9-S%(10**9))
    ans.append(math.ceil(S/(10**9)))
print(*ans)
n, k = map(int,input().split())
from math import factorial
ans = []
for i in range(1, k+1):
    c = factorial(n-k+1) // (factorial(n-k+1 - i) * factorial(i))
    if c == 0:
        break
    ans.append(c)

mod = 10**9 + 7
for j in ans:
    print(j%mod)

### FIXED CODE ###

import math
def C(n,r):
  if n<0 or r<0 or n-r<0:
    return 0
  else:
    return math.factorial(n)//(math.factorial(r)*math.factorial(n-r))
 
n,k=map(int,input().split())
for i in range(1,k+1):
  print(C(n-k+1,i)*C(k-1,i-1)%(10**9+7))