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

N=int(input())

clear_flag=0
for i in range(N):
  txy=list(map(int,input().split()))
  x=0
  y=0
  next_flag=0
  for x_plus in range(txy[0]+1):
    if next_flag==1:
      break
    for x_minus in range(txy[0]+1-x_plus):
      if next_flag==1:
        break
      for y_plus in range(txy[0]+1-x_plus-x_minus):
        if next_flag==1:
          break
        for y_minus in range(txy[0]+1-x_plus-x_minus-y_plus):
          if x_plus+x_minus+y_plus+y_minus==txy[0]:
            #print(x_plus,x_minus,y_plus,y_minus)
            x=x_plus-x_minus
            y=y_plus-y_minus
            if x==txy[1] and y==txy[2]:
            	next_flag=1
            	clear_flag+=1
            	break
            
          
if clear_flag==N:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

N=int(input())

clear_flag=0
for i in range(N):
  txy=list(map(int,input().split()))
  if txy[0]>=(txy[1]+txy[2]) and (txy[0]+txy[1]+txy[2])%2==0:
    clear_flag+=1
  else:
    break
    
if clear_flag==N:
  print("Yes")
else:
  print("No")
### BUGGY CODE ###

from sys import stdin
h,n=[int(x) for x in stdin.readline().rstrip().split()]
ab=[]
for i in range(n):
    ab.append([int(x) for x in stdin.readline().rstrip().split()])

ans=[0]*(h+1)
for i in range(1,h+1):
    li = [ans[max(i-j[0],0)]+j[1] for j in ab]
    ans[i]=min(li)

print(ans[h])

### FIXED CODE ###

from sys import stdin
h,n=[int(x) for x in stdin.readline().rstrip().split()]
ab=[]
for i in range(n):
    ab.append([int(x) for x in stdin.readline().rstrip().split()])

ans=[0]*(h+1)
for i in range(1,h+1):
    li = [ans[max(i-j[0],0)]+j[1] for j in ab]
    ans[i]=min(li)

print(ans[h])
### BUGGY CODE ###

a = int(input())
b = []
for _ in range(a):
  b.append(sorted(list(input())))

ans = 0
for i in range(a):
  for j in range(i+1, a):
    check = True
    for k in range(10):
      if b[i] != b[j]:
        check = False
        break
    if check == True:
      ans += 1
print(ans)

### FIXED CODE ###

a = int(input())
b = {}
strings = ''
ans = 0

for i in range(a):
    check = True
    strings = ''.join(sorted(list(input())))
    if strings not in b.keys():
      check = False
      b[strings] = 1
    if check == True:
      ans += b[strings]
      b[strings] += 1

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

#!/usr/bin/env python3
import sys
from itertools import accumulate
import functools
INF = float("inf")


def solve(N: int, a: "List[int]"):

    dp = [[0]*N for _ in range(N)]
    acc = [0]+list(accumulate(a))

    @functools.lru_cache(maxsize=None)
    def rec(l, r):
        if l == r:
            return 0

        wa = acc[r+1]-acc[l]
        ans = INF
        for k in range(l, r):
            ans = min(rec(l, k) + rec(k+1, r), ans)
        return ans + wa

    print(rec(0, N-1))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
from itertools import accumulate
import functools
sys.setrecursionlimit(10**8)
INF = float("inf")


def solve(N: int, a: "List[int]"):

    dp = [[-1]*N for _ in range(N)]
    acc = [0]+list(accumulate(a))

    def rec(l, r):
        if dp[l][r] > 0:
            return dp[l][r]
        if l == r:
            return 0

        wa = acc[r+1]-acc[l]
        ans = INF
        for k in range(l, r):
            ans = min(rec(l, k) + rec(k+1, r), ans)
        dp[l][r] = ans + wa
        return dp[l][r]

    print(rec(0, N-1))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)


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

import sys
from itertools import groupby

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def len_count(S):
    H, W = len(S), len(S[0])
    L = [[0] * W for _ in range(H)]
    for row_S, row_L in zip(S, L):
        idx = 0
        for k, g in groupby(list(row_S)):
            n = len(list(g))
            if k == '.':
                for i in range(idx, idx + n):
                    row_L[i] = n
            idx += n
    return L


def main():
    H, W = map(int, readline().split())
    S = [readline().strip() for _ in range(H)]

    L1 = len_count(S)
    L2 = list(zip(*len_count(list(zip(*S)))))

    ans = 0
    for row1, row2 in zip(L1, L2):
        for j in range(W):
            if ans < row1[j] + row2[j] - 1:
                ans = row1[j] + row2[j] - 1

    print(ans)
    return


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
from itertools import groupby

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def len_count(S):
    H, W = len(S), len(S[0])
    L = [[0] * W for _ in range(H)]
    for row_S, row_L in zip(S, L):
        vec = [1]
        for i in range(1, W):
            if row_S[i - 1] == row_S[i]:
                vec[-1] += 1
            else:
                vec.append(1)

        idx = 0
        valid = row_S[0] == '.'
        for n in vec:
            if valid:
                for i in range(idx, idx + n):
                    row_L[i] = n
            idx += n
            valid = not valid

    return L


def main():
    H, W = map(int, readline().split())
    S = [readline().strip() for _ in range(H)]

    L1 = len_count(S)
    L2 = len_count(list(zip(*S)))

    ans = 0
    for i in range(H):
        for j in range(W):
            if ans < L1[i][j] + L2[j][i] - 1:
                ans = L1[i][j] + L2[j][i] - 1

    print(ans)
    return


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

#!/usr/bin/python3
# -*- coding: utf-8 -*-
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

n = int(input())
a_list = list(map(int, input().split()))
a_list.sort()
ans2 = a_list[0]
for i in range(1, n):
    ans2 = gcd(ans2, a_list[i])
    if ans2 == 1:
        break

if ans2 != 1:
    print("not coprime")
else:
    flag = 1
    max_a = a_list[n - 1] + 1
    num_flag_list = [True] * max_a
    d_list = list(range(0, max_a))
    d_list[0] = 1
    num_flag_list[0] = num_flag_list[1] = False
    for i in range(2, int(max_a**0.5) + 1):
        if num_flag_list[i]:
            for j in range(i**2, max_a, i):
                if num_flag_list[j] == True:
                    num_flag_list[j] = False
                    d_list[j] = i
    p_set = set()
    for a in a_list:
        if a == 1:
            continue
        temp_p_set = set()
        while True:
            p = d_list[a]
            temp_p_set.add(p)
            a = a // p
            if a == 1:
                break
        if len(p_set & temp_p_set) > 0:
            flag = 0
            break
        else:
            p_set = p_set | temp_p_set
        
    if flag == 1:
        print("pairwise coprime")
    else:
        print("setwise coprime")

### FIXED CODE ###

#!/usr/bin/python3
# -*- coding: utf-8 -*-
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

n = int(input())
a_list = list(map(int, input().split()))
a_list.sort()
ans2 = a_list[0]
for i in range(1, n):
    ans2 = gcd(ans2, a_list[i])
    if ans2 == 1:
        break

if ans2 != 1:
    print("not coprime")
else:
    flag = 1
    max_a = a_list[n - 1] + 1
    num_flag_list = [True] * max_a
    d_list = list(range(0, max_a))
    d_list[0] = 1
    num_flag_list[0] = num_flag_list[1] = False
    for i in range(2, int(max_a**0.5) + 1):
        if num_flag_list[i]:
            for j in range(i**2, max_a, i):
                if num_flag_list[j] == True:
                    num_flag_list[j] = False
                    d_list[j] = i
    p_set = set()
    for a in a_list:
        if a == 1:
            continue
        temp_p_set = set()
        while True:
            p = d_list[a]
            if p not in temp_p_set:
                if p in p_set:
                    flag = 0
                    break
            temp_p_set.add(p)
            p_set.add(p)
            a = a // p
            if a == 1:
                break
        if flag == 0:
            break
        
    if flag == 1:
        print("pairwise coprime")
    else:
        print("setwise coprime")
### BUGGY CODE ###


l     = input().split()
K, S  = map(int, l)
max   = K+1
sum   = 0
count = 0

#print('K= ', K)                                                                                                   
#print('S= ', S)                                                                                                   

for x in range(0, max):
    for y in range(0, max):
        for z in range(0, max):

            sum = x + y + z
            if sum == S:
                count +=1

print(count)


### FIXED CODE ###

l     = input().split()
K, S  = map(int, l)
max   = K+1
count = 0
z     =	0

for x in range(0, max):
    for y in range(0, max):
            z = S - x - y
            if 0 <= z <= K :
                count +=1

print(count)
### BUGGY CODE ###

D, G = map(int, input().split())
p = [list(map(int, input().split())) for _ in range(D)]
plst = [0] * D
ans = 0
for i in range(D):
    ans += p[i][0]

def dfs(n):
    global ans
    if n == D:
        cnt = 0
        total = 0
        for i in range(D):
            if plst[i] == 0:
                continue
            elif plst[i] == 1:
                cnt += p[i][0]
                total += (100 * (i + 1) * p[i][0]) + p[i][1]
        for j in range(D):
            if plst[j] == 2:
                for k in range(p[j][0] - 1):
                    total += (100 * (j + 1))
                    cnt += 1
                    if total >= G:
                        break
        if total >= G:
            ans = min(ans, cnt)
        return

    for i in range(3):
        plst[n] = i
        dfs(n + 1)
    return

dfs(0)
print(ans)

### FIXED CODE ###

D, G = map(int, input().split())
p = [list(map(int, input().split())) for _ in range(D)]
plst = [0] * D
ans = 0
for i in range(D):
    ans += p[i][0]

def dfs(n):
    global ans
    if n == D:
        cnt = 0
        total = 0
        for i in range(D):
            if plst[i] == 0:
                continue
            elif plst[i] == 1:
                cnt += p[i][0]
                total += (100 * (i + 1) * p[i][0]) + p[i][1]
        for j in range(D):
            if plst[j] == 2:
                for k in range(p[j][0] - 1):
                    total += (100 * (j + 1))
                    cnt += 1
                    if total >= G:
                        ans = min(ans, cnt)
        if total >= G:
            ans = min(ans, cnt)
        return

    for i in range(3):
        plst[n] = i
        dfs(n + 1)
    return

dfs(0)
print(ans)
### BUGGY CODE ###

def e_who_says_a_pun():
    N = int(input())
    S = input()

    def z_algorithm(string):
        n = len(string)
        ret = [0] * n
        i, j = 1, 0
        while i < n:
            while i + j < n and string[j] == string[i + j]:
                j += 1
            ret[i] = j
            if j == 0:
                i += 1
                continue
            k = 1
            while i + k < n and k + ret[k] < j:
                ret[i + k] = ret[k]
                k += 1
            i += k
            j -= k
        return ret

    ans = 0
    for i in range(N):
        t = S[i:N]
        lcp = z_algorithm(t)  # Longest Common Prefix
        for j in range(len(t)):
            ans = max(ans, min(lcp[j], j))
    return ans

print(e_who_says_a_pun())

### FIXED CODE ###

def e_who_says_a_pun():
    N = int(input())
    S = input()

    def z_algorithm(string):
        n = len(string)
        ret = [0] * n
        i, j = 1, 0
        while i < n:
            while i + j < n and string[j] == string[i + j]:
                j += 1
            ret[i] = j
            if j == 0:
                i += 1
                continue
            k = 1
            while i + k < n and k + ret[k] < j:
                ret[i + k] = ret[k]
                k += 1
            i += k
            j -= k
        return ret

    ans = 0
    for i in range(N):
        t = S[i:N]
        lcp = z_algorithm(t)  # Longest Common Prefix
        for j in range(len(t)):
            ans = max(ans, min(lcp[j], j))
    return ans

print(e_who_says_a_pun())
### BUGGY CODE ###

import sys
a,b = map(int,input().split())
div_list = []
ans = 0
check = 0
ans_list = []
for i in range(1,min(a,b)):
    if a%i == 0 and b%i == 0:
        div_list.append(i)
if min(a,b) == 1:
    print(1)
    sys.exit()

#print(div_list)
ans_list.append(div_list[1])
for i in range(1,len(div_list)):
    check = 0
    for j in ans_list:
        if div_list[i] % j == 0:
            check = 1
            break
    if check == 0:
        ans_list.append(div_list[i])
ans_list.append(1)
print(len(ans_list))

### FIXED CODE ###

from fractions import gcd
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

a,b = map(int,input().split())
c = gcd(a,b)
d = factorization(c)
print(len(d)+1-(c==1))
### BUGGY CODE ###

N,M = map(int,input().split())
job = {}
for i in range(N):
    A,B = map(int,input().split())
    job.setdefault(A,[]).append(B)
ans = 0
last = min(job.keys())
for i in range(last,M+1):
    option = sorted(job[i])
    if(option != []):
        today = option.pop()
        ans += today
    job.setdefault(i+1,[]).extend(option)
print(ans)

### FIXED CODE ###

import heapq
N,M = map(int,input().split())
AB = sorted([list(map(int,input().split())) for _ in range(N)])

option = []
ans = 0
j = 0
for i in range(1,M+1):
    while j != N and AB[j][0] <= i: 
        heapq.heappush(option,-AB[j][1])
        j += 1
    if len(option) != 0:
        ans -= heapq.heappop(option)
print(ans)
### BUGGY CODE ###

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

parent=dict()
An=set(A)
parecou=0

for i in An:
    f=A.count(i)
    parecou+=int((f*(f-1)/2))



#print(parecou)
for i in range(N):
    anko=A.count(A[i])
    #print(parecou-int((anko*(anko-1)/2))+int(((anko-2)*(anko-1)/2)))
    print(parecou-anko+1)


### FIXED CODE ###

from collections import Counter
N=int(input())
A=list(map(int,input().split()))

parent=dict()
An=set(A)
parecou=0
aaa=Counter(A)
for i in aaa.values():
    parecou+=int((i*(i-1)/2))
"""
for i in An:
    f=A.count(i)
    parent[i]=f
    parecou+=int((f*(f-1)/2))
"""


#print(parecou)
for i in range(N):
    anko=aaa[A[i]]
    print(parecou-int((anko*(anko-1)/2))+int(((anko-2)*(anko-1)/2)))
    #print(parecou-anko+1)
### BUGGY CODE ###

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

ans = 0
for i, p in enumerate(p_list):
  if p == min(p_list[:i+1]):
    ans += 1

print(ans)


### FIXED CODE ###

n = int(input())
p_list = list(map(int, input().split()))
 
mi = p_list[0]
ans = 1
for i in range(1, n):
  if mi >= p_list[i]:
    ans += 1
    mi = p_list[i]
print(ans)
### BUGGY CODE ###

n,k=map(int,input().split())
c=list(map(int,input().split()))
dp=[0]
for i in range(1,n):
    m=min([dp[j]+abs(c[i]-c[j]) for j in range(max(0,i-k),i)])
    dp.append(m)
print(dp[-1])


### FIXED CODE ###

def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    a = [0] * n
    a[0] = 0
    for i in range(1, n):
        a[i] = min([a[j] + abs(h[i] - h[j]) for j in range(max(0, i - k), i)])
    print(a[-1])
 
if __name__ == '__main__':
    main()
### BUGGY CODE ###

import sys
I = lambda:map(int,sys.stdin.readline().split())
pr = lambda x:sys.stdout.write(f'{x}\n')
sys.setrecursionlimit(2000000001)
 
def solve(n,ar,k,dp,x):
	ab = abs; mn = min
	if x>=n-2: return dp[x]
	if dp[x] != -1: return dp[x]
	m = 1e9
	for i in range(x+1,mn(n,x+k+1)):
		t = ab(ar[x]-ar[i])+solve(n,ar,k,dp,i)
		m = t if t<m else m
	dp[x] = m
	return dp[x]
 
def main():
	(n,k), ar = [[*map(int,s.split())] for s in [*open(0)]]
	dp = [-1]*(n-2) + [abs(ar[-2]-ar[-1]),0]
	pr(solve(n,ar,k,dp,0))
 
main()

### FIXED CODE ###

import sys
from functools import reduce
sys.setrecursionlimit(2000000001)

def solve(n,k,ar,dp,x):
	ab = abs; mn = min
	if x>=n-2: return dp[x]
	if not dp[x] is -1: return dp[x]
	# t = [ for i in range(x+1,mn(n,x+k+1))]
	t = map(lambda i:ab(ar[x]-ar[i])+solve(n,k,ar,dp,i), range(x+1,mn(n,x+k+1)))
	dp[x] = reduce(lambda a,b : a if a < b else b,t)
	return dp[x]

def main():
	I = lambda:map(int,sys.stdin.readline().split())
	pr = lambda x:sys.stdout.write(f'{x}\n')
	n,k, ar = *I(), [*I()]
	dp = [-1]*(n-2) + [abs(ar[-2]-ar[-1]),0]
	pr(solve(n,k,ar,dp,0))

main()
### BUGGY CODE ###

import sys
import math
from collections import deque
import heapq
import itertools
from decimal import Decimal
import bisect
from operator import itemgetter
MAX_INT = int(10e18)
MIN_INT = -MAX_INT
mod = 1000000000+7
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def combi(n, r):
  r = min(r, n-r)
  numer = denom = 1
  for i in range(1, r+1):
    numer = numer * (n+1-i) %mod
    denom = denom * i %mod
  return numer * pow(denom, mod-2, mod) %mod

def tami(n, r):
  if r == 0:
    res = kaizyou[n]
    return res %mod
  elif r == 1:
    res = kaizyou[n-1] * (n-1)
    return res %mod
  else:
    return (tami(n-1, r-1) + tami(n-1, r-2) )%mod

N,M = IL()

kaizyou = [0,1]
for i in range(2,N+1):
  kaizyou.append(kaizyou[-1]*i %mod)

ans = 0
for i in range(max(0, 2*N-M), N+1):
  ans += (combi(M, N) %mod * (combi(N, i) * combi(M-N, N-i) ) %mod * tami(N, i)) %mod
print((kaizyou[N] * ans) %mod)

### FIXED CODE ###

import sys
import time
import math
from collections import deque
import heapq
import itertools
from decimal import Decimal
import bisect
from operator import itemgetter
MAX_INT = int(10e18)
MIN_INT = -MAX_INT
mod = 1000000000+7
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

import functools
@functools.lru_cache(maxsize=None)
def factrial_memo(n):
  fact = [1, 1]
  for i in range(2, n + 1):
    fact.append((fact[-1] * i) % mod)
  return fact

def permutation(n,r): #nPr
  return fact[n]*pow(fact[n-r],mod-2,mod)%mod
  
def combination(n,r): #nCr
  return permutation(n,r)*pow(fact[r],mod-2,mod)%mod

def homogeneous(n,r): #nHr
  return combination(n+r-1,r)%mod

N,M = IL()

fact = factrial_memo(10**6)

s = 0
for k in range(1,N+1):
  s += combination(N, k) * permutation(M-k, N-k) * (-1)**(k-1)
ans = (permutation(M, N)**2 - s*permutation(M, N)) %mod
print(ans)
### BUGGY CODE ###

import fractions
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(N):
	if i == N - 1:
		B = A[: N - 1]
	else:
		B = A[: i] + A[i + 1:]
	g = B[0]
	for j in range(1, N - 1):
		g = fractions.gcd(g, B[j])
	ans = max(ans, g)
print(ans)


### FIXED CODE ###

from fractions import gcd
N = int(input())
A = list(map(int, input().split()))
Asort = sorted(A)[:: -1]
L = [0] * N  #左からi番目までのgcdをメモった配列
R = [0] * N  #右からi番目までのgcdをメモった配列
L[0] = A[0]
R[0] = A[N - 1]
for i in range(1, N):
	L[i] = gcd(L[i - 1], A[i])
	R[i] = gcd(R[i - 1], A[N - 1 - i])
ans = max(L[N - 2], R[N - 2])
for j in range(1, N - 1):
	ans = max(ans, gcd(L[j - 1], R[N - j - 2]))
print(ans)
### BUGGY CODE ###

n,k=map(int,input().split())
h=list(map(int,input().split()))
if n<3:
  print(abs(h[0]-h[1]))
  exit()
dp=[0]*(n)
dp[1]=abs(h[0]-h[1])
for i in range(2,n):
  dp[i]=min([dp[i-j]+abs(h[i]-h[i-j]) for j in range(1,min(k+1,i+1))])
print(dp[-1])


### FIXED CODE ###

n,k=map(int,input().split())
import numpy as np
h=np.array(input().split(),np.int64)
if n<3:
  print(abs(h[0]-h[1]))
  exit()
dp=np.zeros(n)
dp[1]=abs(h[0]-h[1])
for i in range(2,n):
  j=max(0,i-k)
  dp[i]=np.min(dp[j:i]+np.abs(h[i]-h[j:i]))
  #dp[i]=min([dp[i-j]+abs(h[i]-h[i-j]) for j in range(1,min(k+1,i+1))])
print(int(dp[-1]))
### BUGGY CODE ###

t = input().split(" ")

N = int(t[0])
K = int(t[1])

p = list(map(int,input().split(" ")))

for i in range(len(p)):
    #a = list(range(1,p[i]+1))
    #print(a)
    p[i] = sum(list(range(1,p[i]+1)))/p[i]

ans = 0
a =0
for i in range(N):
    

    a += p[i]
    
    if i >= K-1:
        
        if i >= K:
            a += -(p[i-K])
        if a > ans:
            ans = a

print(ans)

    
    






### FIXED CODE ###

t = input().split(" ")

N = int(t[0])
K = int(t[1])

p = list(map(int,input().split(" ")))

ans = 0
a =0

for i in range(len(p)):
    #a = list(range(1,p[i]+1))
    #print(a)
    p[i] = ((p[i]*(p[i]+1))/2)/p[i]
    a += p[i]
    
    if i >= K-1:
        
        if i >= K:
            a += -(p[i-K])
        if a > ans:
            ans = a

print(ans)
### 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()))
a.sort(key=lambda x:-x)
b.sort(key=lambda x:-x)
c.sort(key=lambda x:-x)
sumAB=[0 for _ in range(x*y)]
index=0
imax=min(k,x)
jmax=min(k,y)
for i in range(imax):
    for j in range(jmax):
        sumAB[index]=a[i]+b[j]
        index+=1
sumAB.sort(key=lambda x:-x)
beauty=[0 for _ in range(k*k)]
index=0
imax=min(k,x*y)
jmax=min(k,z)
for i in range(imax):
    for j in range(jmax):
        beauty[index]=sumAB[i]+c[j]
        index+=1
beauty.sort(key=lambda x:-x)
for i in range(k):
    print(beauty[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(key=lambda x:-x)
b.sort(key=lambda x:-x)
c.sort(key=lambda x:-x)
beauty=[]
index=0
for i in range(x):
    for j in range(y):
        for l in range(z):
            if (i+1)*(j+1)*(l+1)<=k:
                beauty.append(a[i]+b[j]+c[l])
            else:
                break
beauty.sort(key=lambda x:-x)
for i in range(k):
    print(beauty[i])
### BUGGY CODE ###

n = int(input())
nums = list(map(int, input().split()))
ans = 1
for i in nums:
    ans*= i
if(ans > int(1e18)):
    print(-1)
else:
    print(ans)


### FIXED CODE ###

n = int(input())
nums = list(map(int, input().split()))
ans = 1
ok = True
if(0 in nums):
    print(0)
else:
    for i in nums:
        ans *= i
        if(ans > int(1e18)):
            ok = False
            break
    if(not ok):
        print(-1)
    else:
        print(ans)