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

###template###
import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())
###template###

N, A, B, C, D = mi()
#S[0~N-1]でアクセス
cells = input()

if C > D:
  c = C
  C = D
  D = c
  a = A
  A = B
  B = a

#全部0~N-1ベースにする
A -= 1
B -= 1
C -= 1
D -= 1

#既にスタック済みの座標の組(visited[0~N-1][0~N-1]でアクセス)
visited = [[0]*N for _ in range(N)]

st = []
#初期座標
st.append((A,B))

#結果が出るまでループする
#スタックから座標の組を取り出し、F>Sの優先順位で動かしてスタックに入れる

while 1:
  #選択肢がなくなったら、駄目だったと分かる
  try:
    s, f = st.pop()
  except:
    print('No')
    exit()

  #ここがゴールかどうか
  if s==C and f==D:
    print('Yes')
    exit()
  #Fが動けるかどうか
  fok = 0
  try:
    if visited[s][f+1]==0 and cells[f+1]=='.' and s != f+1:
      st.append((s,f+1))
      visited[s][f+1] = 1
      fok = 1
      continue
  except:
    pass
  try:
    if visited[s][f+2]==0 and cells[f+2]=='.' and s != f+2:
      st.append((s,f+2))
      visited[s][f+2] = 1
      fok = 1
  except:
    pass
  #Fが動けなかった場合のみSが動く
  if fok == 0:
    try:
      if visited[s+2][f]==0 and cells[s+2]=='.' and s+2 != f:
        st.append((s+2,f))
        visited[s+2][f] = 1
        fok = 1
    except:
      pass
    try:
      if visited[s+1][f]==0 and cells[s+1]=='.' and s+1 != f:
        st.append((s+1,f))
        visited[s+1][f] = 1
        fok = 1
    except:
      pass

### FIXED CODE ###

###template###
import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())
###template###

N, A, B, C, D = mi()
#S[0~N-1]でアクセス
cells = input()

#全部0~N-1ベースにする
A -= 1
B -= 1
C -= 1
D -= 1

ans = '?'

goal = max(C,D)


rockcheck = 0 #直前が岩なら1
for i, cell in enumerate(cells):
  if i < A or goal < i: continue
  if rockcheck == 1 and cell == '#':
    ans = 'No'
    break
  elif cell == '#': rockcheck = 1
  else: rockcheck = 0

#C<Dならflag=0, D<Cならflag=1
if C < D: flag = 0
else: flag = 1

if ans == 'No':
  print('No')
  exit()
elif flag == 0: #C<Dならこの時点で勝ち確
  print('Yes')
  exit()
#そうでなければ戦いは続く

ans = 'No'
#C<Dの場合決着がついているので、ここからは必ずD<C
#かつ、##は無いことが保証されている
blankcheck = 0 #直前が.なら1, 直前が..なら2
for i, cell in enumerate(cells):
  if i < (B-1) or (D+1) < i: continue
  if cell == '.': blankcheck += 1
  else: blankcheck = 0
  if blankcheck == 3:
    ans = 'Yes'
    break

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

s = input()
K = int(input())
 
sub_s = []
for i in range(len(s)):
    for j in range(i+1, len(s)+1):
        if s[i:j] not in sub_s and len(s[i:j]) <= K:
            sub_s.append(s[i:j])
 
sub_s = sorted(sub_s)        
#print(sub_s)
print(sub_s[K-1])

### FIXED CODE ###

s = input()
K = int(input())
 
sub_s = []
for i in range(1, K+1):
    for j in range(len(s) - i + 1):
        sub_s.append(s[j:j+i])
 
sub_s = sorted(list(set(sub_s)))        
#print(sub_s)
print(sub_s[K-1])
### BUGGY CODE ###

n = int(input())
ans = 0

for i in range(n):
    ans += i
print(ans)


### FIXED CODE ###

n = int(input())
ans = 0

print((n * (n - 1)) // 2)
### BUGGY CODE ###

import math
k = int(input())

s = 0
for a in range(1, k+1):
  for b in range(1, k+1):
    for c in range(1, k+1):
      g = math.gcd(math.gcd(a, b), c)
      s += g

print(s)


### FIXED CODE ###

k = int(input())

from math import gcd

s = 0
for a in range(1, k+1):
  for b in range(1, k+1):
    g = gcd(a, b)
    for c in range(1, k+1):
      s += gcd(g, c)

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

N = int(input())
s_list = []
for i in range(N):
    s_list.append(input())

def strcount(string):
    dic = {}
    for s in string:
        if s not in dic:
            dic[s] = 1
        else:
            dic[s] += 1
    return dic

cnt = 0
for i in range(N):
    dic = strcount(s_list[i])
    for j in range(i + 1, N):
        #dic = strcount(s_list[i])
        if dic == strcount(s_list[j]):
            cnt += 1
print(cnt)

### FIXED CODE ###

N = int(input())
anagram = {}

ans = 0
for i in range(N):
    tmp = str(sorted(input()))
    if tmp in anagram:
        ans += anagram[tmp]
        anagram[tmp] += 1
    else:
        anagram[tmp] = 1

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

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

result = {}

for count, i in enumerate(A):
    result[count+1] = i

for i in range(N):
    print(list(result.values()).count(i+1))


### FIXED CODE ###

import collections
N = int(input())
strA = input().split()
ans = collections.Counter(strA)
for i in range(1, N+1):
    print(ans[str(i)])
### BUGGY CODE ###

N,K = map(int,input().split())
lst = list(range(0,N+1))
cnt = 0
for i in range(K,N+1):
    start = sum(lst[:i])
    end = sum(lst[-i:])
    cnt += end - start + 1
cnt += 1    
print(cnt)

### FIXED CODE ###

N,K = map(int,input().split())
lst = list(range(0,N+1))
m = 10**9 + 7
cnt = 0
start = sum(lst[:K])
end = sum(lst[-K:])
cnt += end - start + 1
for i in range(K+1,N+2):
    start += lst[i-1] 
    end += lst[-i]
    cnt += end - start + 1
print(cnt % m)
### BUGGY CODE ###

if __name__ == '__main__':
    n = int(input())
    l = list(map(int,input().split()))

    answer = 0
    for i in range(n):
        for j in range(i+1,n):
            for k in range(j+1,n):
                if abs(l[j]-l[k]) < l[i] and l[i] < l[j] + l[k]:
                    answer += 1

    print(answer)


### FIXED CODE ###

import bisect

if __name__ == '__main__':
    n = int(input())
    l = list(map(int,input().split()))

    l = sorted(l)

    answer = 0
    for i in range(0,n):
        for j in range(i+1,n):
            k = bisect.bisect_left(l, l[i]+l[j])
            answer += max(0,k-(j+1))

    print(answer)
### BUGGY CODE ###

import numpy as np

N = int(input())
A_list = map(int, input().split())

# [活発度, もとの番号] のリストを降順に並べる
A_list = [[A, index] for index, A in enumerate(A_list)]
A_list.sort(reverse=True)

# print(A_list)

dp = np.zeros((N+1, N+1), int)
# print(dp)
for left in range(0, N):
    for right in range(0, N - left):
        # print(f'left, righte: { left, right }')
        # print(A_list[left + right - 1][0])
        activity = A_list[left + right][0]
        distance_from_left = A_list[left + right][1] - left
        # print(f'distance_from_left: { distance_from_left }')
        distance_from_right = (N - 1 - right) - A_list[left + right][1]
        # print(f'distance_from_right: { distance_from_right }')
        dp[left + 1][right]\
            = max(dp[left + 1][right],
                  dp[left][right] + activity * distance_from_left)
        dp[left][right + 1]\
            = max(dp[left][right + 1],
                  dp[left][right] + activity * distance_from_right)
        # print('dp---')
        # print(dp)
        # print('---dp')
# print(dp)
print(np.max(dp))


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
table = []
 
for i, a in enumerate(A):
    table.append([a,i])
table.sort()
 
# DP[i][j] 左端に i 個, 右端に j 個貪欲に詰めたときのうれしさ
DP = [[0 for i in range(N+1)] for j in range(N+1)]
for i in range(1,N+1):
    # i 人目 table[i-1] の幼児を移動させる
    baby, pos = table.pop()
    
    DP[i][0] = DP[i-1][0] + baby * abs(pos-i+1)
    DP[0][i] = DP[0][i-1] + baby * abs(pos-(N-i))
    for x in range(1,i):
        y = i - x
 
        #左端に置く場合と右端に置く場合でmax
        DP[x][y] = max(DP[x-1][y] + baby * abs(pos-x+1),\
                     DP[x][y-1] + baby * abs(pos-(N-y)))
 
ans = 0
for i in range(N+1):
    ans = max(ans, DP[i][N-i])
print(ans)
### BUGGY CODE ###

n = int(input())

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

ans = 1

for i in a:
    ans *= i

if ans > pow(10, 18):
    print(-1)
else:
    print(ans)

### FIXED CODE ###

n = int(input())

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

ans = 1

if 0 in a :
    print(0)
    exit()

for i in a:
    if ans*i > pow(10, 18):
        print(-1)
        break
    else:
        ans *= i
else:
    print(ans)
### BUGGY CODE ###

n, k, q = map(int, input().split())
a = [int(input()) for i in range(q)]
class Member:
    def __init__(self, answer):
        self.answer = answer
    def judge(self):
        if self.answer <= q-k:
            return 'No'
        else:
            return 'Yes'
for i in range(n):
    member_i = Member(a.count(i+1))
    print(member_i.judge())

### FIXED CODE ###

n, k, q = map(int, input().split())
a = [int(input()) for i in range(q)]
p = [k for i in range(n)]
def judge(x):
    if p[x] - q <= 0:
        return 'No'
    else:
        return 'Yes'
for i in range(q):
    p[a[i] - 1] += 1
b = [judge(i) for i in range(n)]
print('\n'.join(b))
### BUGGY CODE ###

import sys
input=sys.stdin.readline

R,C,K=map(int,input().split())
rcv=[tuple(map(int,input().split())) for _ in range(K)]

MAP=[[0 for _ in range(C+2)] for _ in range(R+2)]
DP=[[[0 for _ in range(3)] for _ in range(C+2)] for _ in range(R+2)]
for r,c,v in rcv:
    MAP[r-1][c-1]=v

for i in range(R):
    for j in range(C):
        for k in range(3):
            if k==0:
                DP[i][j][k]=max(DP[i][j-1][k],DP[i-1][j][k]+MAP[i][j],
                                DP[i-1][j][k+1]+MAP[i][j],
                                DP[i-1][j][k+2]+MAP[i][j])
            else:
                DP[i][j][k]=max(DP[i][j-1][k],DP[i][j-1][k-1]+MAP[i][j])

ans=0
for i in range(R):
    for j in range(C):
        ans=max(ans,max(DP[i][j]))
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline

R,C,K=map(int,input().split())
J=[tuple(map(int,input().split())) for i in range(K)]

#DP0=[[0]*(C+2) for i in range(R+2)]
DP1=[[0]*(C+2) for i in range(R+2)]
DP2=[[0]*(C+2) for i in range(R+2)]
DP3=[[0]*(C+2) for i in range(R+2)]

MAP=[[0]*C for i in range(R)]

for x,y,v in J:
    MAP[x-1][y-1]=v

for i in range(R):
    for j in range(C):
        DP1[i][j]=max(DP1[i][j-1],DP1[i-1][j]+MAP[i][j],DP2[i-1][j]+MAP[i][j],DP3[i-1][j]+MAP[i][j])
        DP2[i][j]=max(DP2[i][j-1],DP1[i][j-1]+MAP[i][j])
        DP3[i][j]=max(DP3[i][j-1],DP2[i][j-1]+MAP[i][j])

ANS=0
for i in range(R):
    for j in range(C):
        ANS=max(ANS,DP1[i][j],DP2[i][j],DP3[i][j])
print(ANS)
### BUGGY CODE ###

import math
n,x= map(int,input().split())
a = [int(_) for _ in input().split()]
ru = [0]*(n+1)
for i in range(1,n+1):
  ru[i] = ru[i-1]+a[i-1]
ans = float("inf")
for i in range(1,n+1):
  tmp = 0
  l = math.ceil(n/i)
  for j in range(1,l+1):
    if j == 1:
        m = -i*(j+1)-1
        if m < -n:
          m = -n-1
        tmp += (ru[n]-ru[m])*5
    else:
        m = -i*(j+1)-1
        if m < -n:
          m = -n-1
        if -i*j-1 < -n:
          break
        tmp += (ru[-i*j-1]-ru[m])*(2*j+3)
  tmp += x*i
  ans = min(ans,tmp)
print(ans+n*x)

### FIXED CODE ###

import math
n,x= map(int,input().split())
a = [int(_) for _ in input().split()]
ru = [0]*(n+1)
for i in range(1,n+1):
  ru[i] = ru[i-1]+a[i-1]
ans = float("inf")
for i in range(1,n+1):
  tmp = 0
  l = math.ceil(n/i)
  for j in range(1,l+1):
    if j == 1:
        m = -i*(j+1)-1
        if m < -n:
          m = -n-1
        tmp += (ru[n]-ru[m])*5
    else:
        m = -i*(j+1)-1
        if m < -n:
          m = -n-1
        if -i*j-1 < -n:
          break
        tmp += (ru[-i*j-1]-ru[m])*(2*j+3)
  tmp += x*i
  ans = min(ans,tmp)
print(ans+n*x)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(1000000)
F = sys.stdin
S = list(map(int, list(F.readline().replace("A", "1").replace("B", "2").strip("\n"))))
T = list(map(int, list(F.readline().replace("A", "1").replace("B", "2").strip("\n"))))

def initialize(L):
    d, length = 2, len(L)
    while d < length:
        d *= 2
    BT = [0] * (2 * d - 1)
    for i in range(length):
        K = d + i -1
        BT[d + i - 1] = L[i]
        while K > 0:
            K = (K - 1)//2
            BT[K] = (BT[2 * K + 1] + BT[2 * K + 2]) % 3
    return BT

def Search(i, j, l, r, level, BT):
    if r < i or j < l: return 0
    elif i <= l <= r <= j: return BT[level]
    else:
        sl = Search(i, j, l, (l+r)//2, 2*level+1, BT)
        sr = Search(i, j, (l+r)//2 + 1, r, 2*level+2, BT)
        return (sl + sr) % 3


ST, TT = initialize(S), initialize(T)
maxS, maxT = len(ST)//2, len(TT)//2
Ans = ""
Q = int(F.readline().strip("\n"))
for _ in range(Q):
    a, b, c, d = map(int, F.readline().strip("\n").split(" "))
    if Search(a-1, b-1, 0, maxS, 0, ST) == Search(c-1, d-1, 0, maxT, 0, TT): Ans += "YES\n"
    else: Ans += "NO\n"
print(Ans)

### FIXED CODE ###

import sys
F = sys.stdin
S = F.readline().replace("A", "1").replace("B", "2").strip("\n")
T = F.readline().replace("A", "1").replace("B", "2").strip("\n")

sSum = [0] * (len(S)+1)
tSum = [0] * (len(T)+1)
for i in range(len(S)):
    sSum[i+1] = sSum[i] + int(S[i])
for i in range(len(T)):
    tSum[i+1] = tSum[i] + int(T[i])

Ans = ""
Q = int(F.readline().strip("\n"))
for _ in range(Q):
    a, b, c, d = map(int, F.readline().strip("\n").split(" "))
    if (sSum[b] - sSum[a-1]) % 3 == (tSum[d] - tSum[c-1]) % 3: Ans += "YES\n"
    else: Ans += "NO\n"
print(Ans)
### BUGGY CODE ###

import itertools
import math
import fractions
import functools
import copy
from collections import deque
from functools import reduce
from sys import stdin
input = stdin.readline



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

ans = 1
for i in range(n):
    ans *= l[i]

if ans > 10**18:
    print(-1)
else:
    print(ans)


### FIXED CODE ###

import itertools
import math
import fractions
import functools
import copy
from collections import deque
from functools import reduce
from sys import stdin
input = stdin.readline



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

ans = 1
ng = False
for i in range(n):
    if l[i] == 0:
        print(0)
        quit()
    if not ng:
        ans *= l[i]
        if ans > 10**18:
            ng = True

if ng:
    print(-1)
else:
    print(ans)
### BUGGY CODE ###


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

dammy=[]
for x in range(N+1):
    dammy.append((A*x)//B - A * int(x/B))

print(max(dammy))


### FIXED CODE ###

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

W = N//B
dammy=[]
x=N
dammy.append((A*x)//B - A * int(x/B))
x=(B * W)-1
dammy.append((A*x)//B - A * int(x/B))


print(max(dammy))
### BUGGY CODE ###

n = int(input())
a = [int(x) for x in input().split()]
b = []
for i in a:
    b.append(i)
    b = b[::-1]
print(' '.join(map(str, b)))

### FIXED CODE ###

n = int(input())
a = input().split()
a_odd = a[1::2]
a_even = a[0::2]

if n % 2 == 0:
    a_odd.reverse()
    ans = a_odd + a_even
else:
    a_even.reverse()
    ans = a_even + a_odd
print(' '.join(ans))
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
ans=0
mod=10**9+7
lc=a[0]
from fractions import gcd
for i in range(n-1):
	lc=lc*a[i+1]//gcd(lc,a[i+1])
for i in range(n):
	ans+=lc//a[i]
	ans%=mod
print(ans)

### FIXED CODE ###

import copy
n=int(input())
a=list(map(int,input().split()))
b=copy.copy(a)
mod=10**9+7
lcm=[0]*max(a)
for i in range(n):
	for j in range(2,int(a[i]**0.5)+1):
		cnt=0
		while a[i]%j==0:
			a[i]//=j
			cnt+=1
		lcm[j-1]=max(lcm[j-1],cnt)
	if a[i]!=1:
		lcm[a[i]-1]=max(lcm[a[i]-1],1)
an=1
for i in range(len(lcm)):
	an*=pow(i+1,lcm[i],mod)
	an%=mod
ans=0
for i in range(n):
	ans+=an*pow(b[i],mod-2,mod)
	ans%=mod
print(ans)
### BUGGY CODE ###

N, M , Q = map(int, input().split())

LR = [[0]*(N-i) for i in range(N)]
for i in range(M):
  L, R = map(int, input().split())
  for j in range(R-L, N-L+1):
    LR[L-1][j] += 1

for i in range(Q):
  p, q = map(int, input().split())
  S = 0
  for j in range(p-1,q):
    S += LR[j][q-j-1]
  print(S)


### FIXED CODE ###

N, M , Q = map(int, input().split())

LR = [[0]*(N+2-i) for i in range(N+2)]
for i in range(M):
  L, R = map(int, input().split())
  LR[L][R-L+1] += 1

  
for i in range(2,N+2):
  for j in range(1,N-i+2):
    LR[j][i] += LR[j][i-1] + LR[j+1][i-1] - LR[j+1][i-2]
    
for i in range(Q):
  p, q = map(int, input().split())
  print(LR[p][q-p+1]-LR[q+1][0])
### BUGGY CODE ###

n = int(input())
l = []
for i in range(n):
    l.append(int(input()))

result = l[1] - l[0]
for j in range(1, n):
    for i in range(0, j):
        if l[j] - l[i] > result:
            result = l[j] - l[i]
print(result)

### FIXED CODE ###

n = int(input())
maxv = -2 * 10 ** 9
minv = 2 * 10 ** 9
for i in range(n):
    v = int(input())
    maxv = max(maxv, v - minv)
    minv = min(minv, v)
print(maxv)
### BUGGY CODE ###

N=int(input())
L=[]
for i in range(N):
    L.append(int(input()))

L_max=max(L)

for i in range(N):
    now=L[i]
    
    if now!=L_max:
        ans=L_max
        
    else:
        L_temp=L.copy()
        L_temp_p=L_temp.pop(i)
        ans=max(L_temp)
    
    print(ans)

### FIXED CODE ###

N=int(input())
L=[]
for i in range(N):
    L.append(int(input()))

L_max=max(L)

L_max_count=0
for l in L:
    if l==L_max:
        L_max_count+=1
    if L_max_count > 1:
        break

for i in range(N):
    now=L[i]
    
    if L_max_count > 1:
        ans=L_max
    
    elif now!=L_max:
        ans=L_max
        
    else:
        L_temp=L.copy()
        L_temp_p=L_temp.pop(i)
        ans=max(L_temp)
    
    print(ans)
### BUGGY CODE ###

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

D_list = []
for i in range(M):
    B_i, C_i = map(int, input().split())
    D_list += [C_i] * B_i

D_list = sorted(D_list, reverse=True)

# Operate Top N of BC_sorted
len_target = min(len(D_list), N)
for i in range(len_target):
    if A_list[i] < D_list[i]:
        A_list[i] = D_list[i]
    else:
        break

# Output sumed A_list
print(sum(A_list))


### FIXED CODE ###

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

BC_list = [tuple(map(int, input().split())) for _ in range(M)]
BC_list.sort(key=lambda x: x[1], reverse=True)

n_replace = 0
sum_target = 0
is_broken = False
for B, C in BC_list:
    if n_replace + B <= N:
        for A in A_list[n_replace:n_replace+B]:
            if A < C:
                sum_target += C
                n_replace += 1
            else:
                is_broken = True
                break
    else:
        remaining = N - n_replace
        for A in A_list[n_replace:n_replace+remaining]:
            if A < C:
                sum_target += C
                n_replace += 1
            else:
                is_broken = True
                break
    if is_broken is True:
        break
if n_replace < N:
    sum_target += sum(A_list[n_replace:])

# Output sumed A_list
print(sum_target)
### BUGGY CODE ###

n = int(input())
c = list(input())

if "W" not in c:
  print(0)
  exit()

elif "R" not in c:
  print(0)
  exit()

w = c.index("W")
r = n-1 - c[::-1].index("R")

cnt = 0
while w < r:
  c[w],c[r] = c[r],c[w]
  w = c.index("W")
  r = n-1 - c[::-1].index("R")
  cnt += 1
else:
  print(cnt)

### FIXED CODE ###

n = int(input())
c = list(input())

r = c.count('R')  
wr = c[:r].count('W')  

print(wr)
### BUGGY CODE ###

import sys
import copy
sys.setrecursionlimit(10**7)

def dfs(number_list, memo_number):
    for number in number_list:
        if number in check_list:
            continue
        point = ans[memo_number]
        check_list.append(number)

        ans[number] += point
        dfs(graph[number], number)
    

n, q = map(int, input().split())
li_ab = [list(map(int, input().split())) for _ in range(n-1)]
li_px = [list(map(int, input().split())) for _ in range(q)]

graph = [[] for _ in range(n+10)]
for a,b in li_ab:
    graph[a].append(b)
    graph[b].append(a)

ans = [0 for _ in range(n+1)]
for p,x in li_px:
    ans[p] += x

check_list = [1]
point = 0
dfs(graph[1], 1)
    
print(*ans[1:])


### FIXED CODE ###

n, q = map(int, input().split())
li_nq = [list(map(int, input().split())) for _ in range(n-1)]
li_px = [list(map(int, input().split())) for _ in range((q))]

graph = [[] for _ in range(n+1)]
for i, j in li_nq:
    graph[i].append(j)
    graph[j].append(i)

ans = [0 for _ in range(n+1)]
for i, j in li_px:
    ans[i] += j

check_list = [None] * (n+1)
stack = [1]

while stack:
    num = stack.pop()
    for i in graph[num]:
        if check_list[num] == i:
            continue
        stack.append(i)
        ans[i] += ans[num]
        check_list[i] = num

print(*ans[1:])
### BUGGY CODE ###

n = int(input())
lst = [int(i) for i in input().split()]
dic = {}
for i in range(n):
  if lst[i] not in dic:
    dic[lst[i]] = 1
  else:
    dic[lst[i]] += 1
#print(dic)
dic2 = {}
for key, value in dic.items():
  dic2[key] = [value * (value - 1) // 2, (value - 1) * (value - 2) // 2]
ans = {}
for i in range(n):
  count = 0
  m = lst[i]
  if m not in ans:
    for key, value in dic2.items():
      if key == m:
        count += value[1]
      else:
        count += value[0]
    ans[m] = count
  else:
    count = ans[m]
  print(count)

### FIXED CODE ###

n = int(input())
lst = [int(i) for i in input().split()]
dic = {}
for i in range(n):
  if lst[i] not in dic:
    dic[lst[i]] = [1, 0, 0]
  else:
    dic[lst[i]][0] += 1
    dic[lst[i]][1] = dic[lst[i]][0] * (dic[lst[i]][0] - 1) // 2
    dic[lst[i]][2] = (dic[lst[i]][0] - 1) * (dic[lst[i]][0] - 2) // 2
#print(dic)
count = 0
for value in dic.values():
  count += value[1]
for i in range(n):
  m = lst[i]
  count -= dic[m][1]
  count += dic[m][2]
  print(count)
  count += dic[m][1]
  count -= dic[m][2]
### BUGGY CODE ###

import sys
readline = sys.stdin.readline
flush = sys.stdout.flush
def query(x):
    print("%d\n" % x)
    flush()
    # ジャッジから返される値を取得
    return readline().strip()


n = int(input())

right = n
left = -1

print(0, flush = True)
lefti = input()

print(n-1, flush = True)
righti = input()

while True:
    mid = left + (right-left)//2
    midi = query(mid)
    if midi == "Vacant":
        exit(0)
    if (lefti == midi and (mid - left) % 2 == 1) or ((lefti != midi) and (mid - left) % 2 == 0):
        righti = midi
        right = mid
    else:
        lefti = midi
        left = mid


### FIXED CODE ###

import sys
readline = sys.stdin.readline
flush = sys.stdout.flush
def query(x):
    print("%d\n" % x)
    flush()
    # ジャッジから返される値を取得
    return readline().strip()


n = int(input())

right = n-1
left = 0

print(0, flush = True)
lefti = input()
if lefti == "Vacant":
    exit(0)
print(n-1, flush = True)
righti = input()
if righti == "Vacant":
    exit(0)

while True:
    mid = left + (right-left)//2
    midi = query(mid)
    if midi == "Vacant":
        exit(0)
    if (lefti == midi and (mid - left) % 2 == 1) or ((lefti != midi) and (mid - left) % 2 == 0):
        righti = midi
        right = mid
    else:
        lefti = midi
        left = mid
### BUGGY CODE ###

X, Y, Z, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

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

ABC = []
for ab in AB[:K]:
    for c in C[:K]:
        ABC.append(ab + c)
ABC.sort(reverse=True)

for abc in ABC[:K]:
    print(abc)


### FIXED CODE ###

X, Y, Z, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

AB = [a + b for a in A for b in B]
AB.sort(reverse=True)
ABC = [ab + c for ab in AB[:K] for c in C[:K]]
ABC.sort(reverse=True)
[print(abc) for abc in ABC[:K]]