Harryxun/stf_run huggingface dataset:
# from fractions import gcd
# mod = 10 ** 9 + 7
# N = int(input())
# a = list(map(int,input().split()))
# a,b,c = map(int,input().split())
# ans = [0] * N
# math.ceilで切り上げ
# dp = [[0] * 4 for i in range(3)] #2次元配列初期化
# dp = [[[0] * 2 for i in range(3)] for j in range(5)]
# (ord('A'))でASCII出力 Aは65
import math
import statistics
import string


def intinput():
    return int(input())
def listintinput():
    return list(map(int, input().split()))
def splitintinput():
    return map(int, input().split())
def factorialsurplus(x, y, z):  # xからyまでの階乗をzで割ったあまりを求める
    ret = 1
    for i in range(x, y + 1):
        ret = (ret * i) % z
    return (ret)
def isprime(x):
    if x == 1:
        return False
    if x == 2:
        return True
    sq = int(math.sqrt(x))
    for i in range(2,sq+1):
        if x % i == 0:
            return False
    return True
def hcfnaive(a,b):#最大公約数 math.gcdが使えない時の手段として入れとく。pythonが更新されたらいらなくなるはず
    if(b==0):
        return a
    else:
        return hcfnaive(b,a%b)

s = input()
Q = intinput()
rev_count = 0

for i in range(Q):
    a = input()
    if a[0] == "1":
        rev_count += 1
    else:
        b = a.split()
        if rev_count % 2 == 0:
            if b[1] == "1":
                s = b[2] + s
            else:
                s = s + b[2]
        else:
            if b[1] == "1":
                s = s + b[2]
            else:
                s = b[2] + s

if rev_count % 2 == 0:
    print(s)
else:
    print(s[::-1])



### FIXED CODE ###

# from fractions import gcd
# mod = 10 ** 9 + 7
# N = int(input())
# a = list(map(int,input().split()))
# a,b,c = map(int,input().split())
# ans = [0] * N
# math.ceilで切り上げ
# dp = [[0] * 4 for i in range(3)] #2次元配列初期化
# dp = [[[0] * 2 for i in range(3)] for j in range(5)]
# (ord('A'))でASCII出力 Aは65
import math
import statistics
import string
import sys
from array import array
from collections import deque

def intinput():
    return int(input())
def listintinput():
    return list(map(int, input().split()))
def splitintinput():
    return map(int, input().split())
def factorialsurplus(x, y, z):  # xからyまでの階乗をzで割ったあまりを求める
    ret = 1
    for i in range(x, y + 1):
        ret = (ret * i) % z
    return (ret)
def isprime(x):
    if x == 1:
        return False
    if x == 2:
        return True
    sq = int(math.sqrt(x))
    for i in range(2,sq+1):
        if x % i == 0:
            return False
    return True
def hcfnaive(a,b):#最大公約数 math.gcdが使えない時の手段として入れとく。pythonが更新されたらいらなくなるはず
    if(b==0):
        return a
    else:
        return hcfnaive(b,a%b)

s = deque()
s.append(input())
Q = int(input())
rev_count = 0

for i in range(Q):
    a = input()
    if a[0] == "1":
        rev_count += 1
    else:
        b = a.split()
        if rev_count % 2 == 0:
            if b[1] == "1":
                s.appendleft(b[2])
            else:
                s.append(b[2])
        else:
            if b[1] == "1":
                s.append(b[2])
            else:
                s.appendleft(b[2])

if rev_count % 2 == 0:
    print(''.join(s))
else:
    a = ''.join(s)
    print(a[::-1])
N, K = map(int, input())

if (2*(K-1) + 1 <= N):
    print('YES')
else:
    print('NO')


### FIXED CODE ###

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

if (2*(K-1) + 1 <= N):
    print('YES')
else:
    print('NO')
n = [i for i in input().split()]
a = n[1]
b = n[2]
if a <10:
  b += (10-a)*100
print(b)

### FIXED CODE ###

n = [int(i) for i in input().split()]
a = n[0]
b = n[1]
if a < 10:
  b += (10-a)*100
print(b)
N, K = map(int, input().split())
l = list(map(int, input().split()))

ans = 0
for i in range(K):
	m = max(l)
	ans += m
	l[l.find(str(m))] = 0
print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
l = list(map(int, input().split()))

ans = 0
for i in range(K):
	m = max(l)
	ans += m
	l[l.index(m)] = 0
print(ans)
n = int(input())
arr = list(map(int,input().split()))
xors = 0
for val in arr:
  xors^=val
ans = []
for i in range(n):
  ans.append(xros^arr[i])
  
print(*ans)

### FIXED CODE ###

n = int(input())
arr = list(map(int,input().split()))
xors = 0
for val in arr:
  xors^=val
ans = []
for i in range(n):
  ans.append(xors^arr[i])
  
print(*ans)
[a,b,h,m] = input().split(" ")

short = (h*60+m)/(12*60)*360
long = (m)/(60)*360
theta = min(abs(long-short),abs(short-long))

print(a*2+b*2+a*b*cos(theta))

### FIXED CODE ###

import math
 
[a, b, h, m] = [int(x) for x in input().split(" ")]
short = ((h) * 60 + m) / (12 * 60) * 360
long = (m) / (60) * 360
theta = abs(long - short)
inte = math.cos(math.radians(theta))
print(math.sqrt(a ** 2 + b ** 2- 2*a * b * inte))
n = str(input())
p = int(input())

keta = len(n)
Dp = [[[0 for _ in range(2)] for _ in range(keta+1)]for _ in range(keta+1)]

Dp[0][0][1] = 1

for i in range(keta):
    for j in range(i+1):
        for k in range(10):
            if k == 0:
                if k < int(n[i]):
                    Dp[i+1][j][0] += Dp[i][j][0]
                    Dp[i+1][j][0] += Dp[i][j][1]
                    
                elif k == int(n[i]):
                    Dp[i+1][j][1] += Dp[i][j][1]
                    Dp[i+1][j][0] += Dp[i][j][0]
                
                else:
                    Dp[i+1][j][0] += Dp[i][j][0]
            
            else:
                if k < int(n[i]):
                    Dp[i+1][j+1][0] += Dp[i][j][0]
                    Dp[i+1][j+1][0] += Dp[i][j][1]
                elif k == int(n[i]):
                    Dp[i+1][j+1][1] += Dp[i][j][1]
                    Dp[i+1][j+1][0] += Dp[i][j][0]
                else:
                    Dp[i+1][j+1][0] += Dp[i][j][0]

print(sum(Dp[-1][p]))

### FIXED CODE ###

n = str(input())
p = int(input())

keta = len(n)
Dp = [[[0 for _ in range(2)] for _ in range(keta+1)]for _ in range(keta+1)]

Dp[0][0][1] = 1
10
for i in range(keta):
    for j in range(i+1):
        for k in range(10):
            if k == 0:
                if k < int(n[i]):
                    Dp[i+1][j][0] += Dp[i][j][0]
                    Dp[i+1][j][0] += Dp[i][j][1]
                    
                elif k == int(n[i]):
                    Dp[i+1][j][1] += Dp[i][j][1]
                    Dp[i+1][j][0] += Dp[i][j][0]
                
                else:
                    Dp[i+1][j][0] += Dp[i][j][0]
            
            else:
                if k < int(n[i]):
                    Dp[i+1][j+1][0] += Dp[i][j][0]
                    Dp[i+1][j+1][0] += Dp[i][j][1]
                elif k == int(n[i]):
                    Dp[i+1][j+1][1] += Dp[i][j][1]
                    Dp[i+1][j+1][0] += Dp[i][j][0]
                else:
                    Dp[i+1][j+1][0] += Dp[i][j][0]

if p > keta:
    print(0)
else:
    print(sum(Dp[-1][p]))
pqr = [int(i) for i in input().split('')]

x = p+q
y = q+r
z = r+p

print(min([x,y,z]))

### FIXED CODE ###

p,q,r = [int(i) for i in input().split(' ')]

x = p+q
y = q+r
z = r+p

print(min([x,y,z]))
import collections

N = int(input())

List = {}
for i in range(N):
    A = int(input())
    if List.get(A,None)==None:
        List[A]=1
    else:
        del List[A]

c = collections.Counter(List)
if(c.most_common(1)[0][1]==0):
    print(0)
    exit()

print(len(c))


### FIXED CODE ###

import collections

N = int(input())

List = {}
for i in range(N):
    A = int(input())
    if List.get(A,None)==None:
        List[A]=1
    else:
        del List[A]

c = collections.Counter(List)

print(len(c))
n = int(input())

if n < 10:
    print(n)
elif n < 100:
    print("9")
elif n < 1000:
    print(n-90)
elif n < 10000:
    print("909")
elif n < 100000
    print(n-9090)
else:
    print("90909")

### FIXED CODE ###

n = int(input())

if n < 10:
    print(n)
elif n < 100:
    print("9")
elif n < 1000:
    print(n-90)
elif n < 10000:
    print("909")
elif n < 100000:
    print(n-9090)
else:
    print("90909")
N = int(input())
L = map(int, input().split())
x = sorted(L)
Lmax = max(L)
y = x[0:-1]
ysum = sum(y)
print("Yes" if Lmax < ysum else "No")

### FIXED CODE ###

N = int(input())
L = list(map(int, input().split()))
x = sorted(L)
Lmax = max(L)
y = x[0:-1]
ysum = sum(y)
print("Yes" if Lmax < ysum else "No")
import fractions

def lcm(num_list):
    if len(num_list) > 2:
        num_list_new = [lcm(num_list[:2])]
        num_list_new.extend(num_list[2:])
        return lcm(num_list_new)
    elif len(num_list) == 2:
        return num_list[0] * num_list[1] // fractions.gcd(num_list[0], num_list[1])

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

lcm_of_a = lcm(a)
count = M * 2 // lcm_of_a
if count % 2 == 0:
    print(count // 2)
else:
    print((count + 1) // 2)


### FIXED CODE ###

from fractions import gcd
from functools import reduce
import sys

def lcm(nums):
    return reduce(lambda x, y: x * y // gcd(x, y), nums)

n, m = map(int, input().split())
a = [int(item) // 2 for item in input().split()]
b = [0] * n

for i in range(n):
    tmp = a[i]
    while True:
        if tmp % 2 == 0:
            b[i] += 1
            tmp /= 2
        else:
            break

if len(set(b)) != 1:
    print(0)
    sys.exit()

a_lcm = lcm(a)
count = m // a_lcm
if count % 2 == 0:
    print(count // 2)
else:
    print((count + 1) // 2)
n=int(input())
s,t=map(input().split())
result=''
for i in range(0,n):
    result+=s[i]
    reuslt+=t[i]
print(result)


### FIXED CODE ###

n=int(input())
s,t=map(str,input().split())
result=''
for i in range(0,n):
    result+=s[i]
    result+=t[i]
print(result)
l,r=map(int,input().split())
if r-l>=2019: print(0)
else:
    ans=2018
    mod_l=l%2019
    mod_r=r%2019
    for i in range(min(mod_l,mod_r),max(mod_l,mod_r)+1):
        for j in range(i+1,max(mod_l,mod_r)+1):
            mod=(i*j)%2019
            if mod<ans: ans=mod
            else: continue
print(ans)

### FIXED CODE ###

l,r=map(int,input().split())
if r-l>=2019: print(0)
else:
    ans=2018
    mod_l=l%2019
    mod_r=r%2019
    for i in range(min(mod_l,mod_r),max(mod_l,mod_r)+1):
        for j in range(i+1,max(mod_l,mod_r)+1):
            mod=(i*j)%2019
            if mod<ans: ans=mod
    print(ans)
ef dfs (i,depth):

    if i >= depth-1:
        return 'bpppb'
    else:
        s = dfs(i+1,depth)
        return 'b' + s + 'p' + s + 'b'

n,x = map(int,input().split())

p = 2**(n+1)-1
b = 2**(n+1)-2
a = p + b
#print(p,a,b)
pos = a / x
#print(pos)
#print(p / pos)

r = dfs(0,n)
print(r.count('p',0,x))


### FIXED CODE ###

a = []
p = []

def dfs (x,i,depth):

    if i <= 1:
        #print(x)
        if x == 0:
            return 0
        elif x == 1:
            return 1
        elif x == 2:
            return 2
        elif x >= 3:
            return 3
    else:
        #print(a[i],a[i]//2,x)
        if a[i]//2 < x  :
            x = x - a[i]//2 - 1
            #print("right>>>",p[i-1] + 1,x)
            return (p[i-1] + 1) + dfs(x,i-1,depth)
        elif a[i]//2 == x :
            #print("<<<mid>>>",1,x)
            return (1 + dfs(x-1,i-1,depth))
        else:
            #print("left<<<",0,x)
            if x - 1 <= 0:
                return 0
            else:
                return dfs(x-1,i-1,depth)

def ddff (i,depth):
    if i >= depth-1:
        return 'bpppb'
    else:
        return 'b' + ddff(i+1,depth) + 'p' + ddff(i+1,depth) + 'b'
 
n,x = map(int,input().split())

for i in range(n+1):
    p.append(2**(i+1)-1)
    b = 2**(i+1)-2
    a.append(p[i] + b)
#print(a,p)

r = dfs(x-1,n,n)
print(r)
a = raw_input()
a = a * a * a
print(a)

### FIXED CODE ###

a = int(input())
print(pow(a,3))
a = int(input())
p = list(map(int,input().split()))
 count = 0
  
for i in range(a):
     for s in range(a):
         for t in range(a):
             if p[t]<p[s]<p[i] and p[t]+p[s]>p[i]:
                 count+=1
print(count)

### FIXED CODE ###

num = list(map(str,input()))
if num[0]== 'R' and num[1] =='S':
    print('1')
else:
    print(num.count('R'))
N = int(input())

FIELD_SIZE = 101

x = []
y = []
h = []
for n in range(N):
    inputs = input().split()
    x.append(int(inputs[0]))
    y.append(int(inputs[1]))
    h.append(int(inputs[2]))

H = [[-1] * FIELD_SIZE for n in range(FIELD_SIZE)]
under_flag = True

for n in range(N):
    for cx in range(FIELD_SIZE):
        for cy in range(FIELD_SIZE):
            if h[n] != 0:
                under_flag = False

            ch = h[n] + abs(x[n] - cx) + abs(y[n] - cy)
            if H[cx][cy] == -1:
                H[cx][cy] = ch
            elif under_flag and ch <= H[cx][cy]:
                H[cx][cy] = ch
            elif h[n] != 0 and H[cx][cy] == ch:
                H[cx][cy] = ch
            elif h[n] == 0 and H[cx][cy] <= ch:
                pass
            else:
                H[cx][cy] = None

for cx in range(FIELD_SIZE):
    for cy in range(FIELD_SIZE):
        if H[cx][cy] is not None:
            print(cx, cy, H[cx][cy])


### FIXED CODE ###

#!/usr/bin/env python

N = int(input())

FIELD_SIZE = 101

x = []
y = []
h = []
for n in range(N):
    inputs = input().split()
    x.append(int(inputs[0]))
    y.append(int(inputs[1]))
    h.append(int(inputs[2]))

H = [[0] * FIELD_SIZE for n in range(FIELD_SIZE)]
determined_flag = False

for n in range(N):
    for cx in range(FIELD_SIZE):
        for cy in range(FIELD_SIZE):

            ch = h[n] + abs(x[n] - cx) + abs(y[n] - cy)
            if n == 0:
                H[cx][cy] = ch

            elif determined_flag:
                if h[n] != 0:
                    if ch == H[cx][cy]:
                        pass
                    else:
                        H[cx][cy] = 0
                else:
                    if ch >= H[cx][cy]:
                        pass
                    else:
                        H[cx][cy] = 0

            else:
                if h[n] != 0:
                    if ch <= H[cx][cy]:
                        H[cx][cy] = ch
                    else:
                        H[cx][cy] = 0
                else:
                    H[cx][cy] = min(H[cx][cy], ch)
    if h[n] != 0:
        determined_flag = True


for cx in range(FIELD_SIZE):
    for cy in range(FIELD_SIZE):
        if H[cx][cy] >= 1:
            print(cx, cy, H[cx][cy])
n=int(input())
lst=[]
for i in range(n):
  a,b,c=map(int,input().split())
  lst.append([a,b,c])
C=[[float('inf')]*3]*n
C[0][0]=lst[0][0]
C[0][1]=lst[0][1]
C[0][2]=lst[0][2]
D=[0,1,2]
d=D
for i in range(n-1):
  for j in d:
    D=d
    e=D.remove(j)
    C[i+1][j]=C[i][e[0]]+lst[i][e[0]]
    for k in range(1,len(e)):
      if C[i][e[k]]+lst[i][e[k]]>C[i+1][j]:
        C[i+1][j]=C[i][e[k]]+lst[i][e[k]]
print(max(C[n-1]))
      
    
  
  


### FIXED CODE ###

n=int(input())
lst=[]
for i in range(n):
  a,b,c=map(int,input().split())
  lst.append([a,b,c])
C=[]
for i in range(n):
    C.append([float('inf')]*3)
C[0][0]=lst[0][0]
C[0][1]=lst[0][1]
C[0][2]=lst[0][2]
D=[0,1,2]
for i in range(n-1):
  for j in [0,1,2]:
    del D[j]
    C[i+1][j]=max(C[i][D[0]]+lst[i+1][j],C[i][D[1]]+lst[i+1][j])
    D=[0,1,2]
print(max(C[n-1]))
s = int(input())
lis = []

def func(n):
    if n%2 == 0:
        return n//2
    else:
        return 3*n+1
 
while func(s) !=4:
    print(func(s))
    s = func(s)
    lis.append(s)
    
print(int(len(lis)+5))

### FIXED CODE ###

a, b, c = map(int, input().split())
S = (1/2)*a*b*c/max(a,b,c)
print(int(S))
s, t = input().split()
printf(s+t)

### FIXED CODE ###

s, t = input().split()
print(t+s)
b, c = map(int, input().split())
if b<c :
  print("0")
else if :
  print("10")
  


### FIXED CODE ###

b, c = map(int, input().split())
num1 = 0
num2 = 10
if b<c:
  print(str(num1))
else:
  print(str(num2))
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n = I()
    d = collections.defaultdict(set)
    for _ in range(n-1):
        a,b = LI()
        d[a].add(b)
        d[b].add(a)

    f = collections.defaultdict(bool)
    rf = False
    def g(s, h, m):
        t = list(d[s] - set([m]))[-1]
        if len(d[t]) > 2:
            if h:
                if f[t] and not rf:
                    return True
                f[t] = True
            else:
                d[t].remove(s)
                d[s].remove(t)
                rf = True
            return False
        if len(d[t]) == 1:
            return not h
        return g(t,not h,s)

    t = True
    gf = collections.defaultdict(bool)
    while t:
        if rf:
            gf = collections.defaultdict(bool)
            f = collections.defaultdict(bool)
            rf = False
        t = False
        for k,v in list(d.items()):
            if len(v) == 1:
                if gf[k]:
                    continue
                gf[k] = True
                res = g(k, True, -1)
                if res:
                    return 'First'
                t = True
    return 'Second'


print(main())


### FIXED CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n = I()
    d = collections.defaultdict(set)
    kk = None
    for _ in range(n-1):
        a,b = LI()
        kk = [a,b]
        d[a].add(b)
        d[b].add(a)

    tt = True
    gf = collections.defaultdict(bool)
    while tt:
        tt = False
        for k,v in list(d.items()):
            if len(v) == 1:
                vt = list(v)[0]
                if len(d[vt]) == 1:
                    continue
                for vv in d[vt]:
                    if vv == k:
                        continue
                    if vt in d[vv]:
                        d[vv].remove(vt)
                d[vt] = set([k])
                tt = True
            elif len(v) == 0:
                return 'First'
    return 'Second'


print(main())
N = int(input())
d = [[i] for i in int(input())]
N = int(input())
d = [int(input()) for i in range(N)]
N = int(input())
d = [int(input()) for i in range(N)]
print(len(set(d)))

### FIXED CODE ###

N = int(input())
d = [int(input()) for i in range(N)]
print(len(set(d)))
W,H,x,y,r = map(int,input().split())

w,h = W-r,H=r

if x<w and y<h: print('Yes')

else: print('No')


### FIXED CODE ###

W,H,x,y,r = map(int,input().split())



if x-r<0 or W<x+r or y-r<0 or H<y+r: print('No')

else: print('Yes')
mod = 2019
for i in range(100):
  if L <= 3**i <= R or L <= 673**i <= R or L <= 3*673*i <= R or L <= 3*i <= R or L <= 673*i <= R or L <= 3*673**i <= R:
    print(0)
    exit()
else:
  print(min((L*(L+1))%mod, R*(R-1)%mod, R*L%mod))

### FIXED CODE ###

L, R = map(int,input().split())

R = min(R, L+673)
ans = 2018
for i in range(L, R+1):
  for j in range(i+1, R+1):
    ans = min(ans, i*j%2019)
print(ans)
a,s,c=map(str,input().split())
print(f'{a[0]}{s[0]}{c[0]}')

### FIXED CODE ###

a,s,c=input().split()
print(a[0]+s[0]+c[0])
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
n=int(input())
li=[]
f=make_divisors(n)
for i in range(1,n+1):
    li.append(i*f[i-1])
print(sum(li))

### FIXED CODE ###

n=int(input())

#L=[n//i*(i+n//i*i)//2 for i in range(1,n+1)]
#print(sum(L))
ans=0
#for i in range(1,n+1):
#    for j in range(1,n+1):
#        if i%j==0:
#            ans+=i
#print(ans)
g=lambda x:(x*(n//x)*(n//x+1))//2
print(sum(g(i) for i in range(1,n+1)))
K = int(input())
A, =B map(int,input().split())

if B // K < A // K :
    print('OK')
else :
    print('NG')

### FIXED CODE ###

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

if A % K == 0:
    print('OK')
else:
    m = A // K
    if (m + 1) * K <= B:
        print('OK')
    else:
        print('NG')
import heapq
sys.setrecursionlimit(1000000)
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)

q = []
ans = []
flag = []
first = [A[0] + B[0] + C[0], [0, 0, 0]]
heapq.heappush(q, first)
flag.append(first[1])
for h in range(k):
    max_ans = heapq.heappop(q)
    ans.append(abs(max_ans[0]))
    i, j, k = max_ans[1]
    if i == len(A)-1:
        i = i-1
    if j == len(B)-1:
        j = j-1
    if k == len(C)-1:
        k = k-1

    lst1 =  [-A[i+1]-B[j]-C[k], [i+1, j, k]]
    if lst1[1] not in flag:
        heapq.heappush(q, lst1)
        flag.append(lst1[1])

    lst2 = [-A[i]-B[j+1]-C[k], [i, j+1, k]]
    if lst2[1] not in flag: 
        heapq.heappush(q, lst2)
        flag.append(lst2[1])

    lst3 = [-A[i]-B[j]-C[k+1], [i, j, k+1]]
    if lst3[1] not in flag:
        heapq.heappush(q, lst3)
        flag.append(lst3[1])
    print(ans[h])

### FIXED CODE ###

import heapq
x, y, z, w = 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)

q = []
ans = []
flag = []
first = [A[0] + B[0] + C[0], [0, 0, 0]]
heapq.heappush(q, first)
flag.append(first[1])
for h in range(w):
    max_ans = heapq.heappop(q)
    ans.append(abs(max_ans[0]))
    i, j, k = max_ans[1]

    if i == x-1:
        lst1 =  [-A[i]-B[j]-C[k], [i, j, k]]
    else:
        lst1 =  [-A[i+1]-B[j]-C[k], [i+1, j, k]]
    if lst1[1] not in flag:
        heapq.heappush(q, lst1)
        flag.append(lst1[1])

    if j == y-1:
        lst2 = [-A[i]-B[j]-C[k], [i, j, k]]
    else:
        lst2 = [-A[i]-B[j+1]-C[k], [i, j+1, k]]
    if lst2[1] not in flag: 
        heapq.heappush(q, lst2)
        flag.append(lst2[1])

    if k == z-1:
        lst3 = [-A[i]-B[j]-C[k], [i, j, k]]
    else:
        lst3 = [-A[i]-B[j]-C[k+1], [i, j, k+1]]
    if lst3[1] not in flag:
        heapq.heappush(q, lst3)
        flag.append(lst3[1])
    
    print(ans[h])
#17:09
n,k = map(int,input().split())
v = list(map(int,input().split()))
'''
左からa個
右からb個
k-a-b個以内捨てて良し
'''
can = []
nk = min(n,k)
for a in range(nk+1):
  if a != 0:
    x.append(v[a-1])
  else:
    x = []
  for b in range(nk+1-a):
    if b != 0:
      y.append(v[-b])
    else:
      y = []
    z = x + y
    z.sort()
    r = k - a - b
    tmp = 0
    if r < a+b:
      if z[r] < 0:
        for i in range(r,a+b):
          tmp += z[i]
      else:
        for i in range(a+b):
          if z[i] >= 0:
            tmp += z[i]
    else:
      for i in range(a+b):
        if z[i] >= 0:
          tmp += z[i]
    can.append(tmp)
print(max(can))

### FIXED CODE ###

a,p = map(int,input().split())
print((3*a+p)//2)
n=int(input())
a=list(map(int,input().split()))
ans=[0]*n
for i in range(n-1,-1,-1):
  x=(sum(ans[i-1::i]))%2
  if x!=a[i]:
    ans[i]=1
print(sum(ans))

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
ans=[0]*n
for i in range(n-1,-1,-1):
  x=(sum(ans[i::i+1]))%2
  if x!=a[i]:
    ans[i]=1
print(sum(ans))
for i in range(n):
  if ans[i]==1:
    print(str(i+1)+" ",end="")