Harryxun/stf_run huggingface dataset:
import sys; sys.setrecursionlimit(50000)
input = sys.stdin.readline

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)

cnt = 0
result = [0]*K
for x in range(X):
    for y in range(Y):
        if x * y > K: break
        for z in range(Z):
            if x * y * z > K: break
            result[cnt] = A[x]+B[y]+C[z]
            cnt += 1
result.sort(reverse=True)
for i in range(K):
    print(result[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()))

import itertools
AB = [a + b for a, b in itertools.product(A,B)]
AB.sort(reverse=True)
ABC = [ab + c for ab, c in itertools.product(AB[:3000],C)]
ABC.sort(reverse=True)
for i in range(K):
    print(ABC[i])
judge=0
j,k=A,B
for i in range(1,4):
	if (j+k+i)*2==1:
      judge=1
if judge==1:
  print ("Yes")
else:
  print ("No")

### FIXED CODE ###

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

judge=0
for C in range(1,4):
  if (A*B*C)%2==1:
    judge=1

if judge==1:
  print ("Yes")
else:
  print ("No")
n = int(input())
p = list(map(int,input().split()))
p.sort() 
ans = p[n/2] - p[n/2-1]
print(ans)

### FIXED CODE ###

n = int(input())
p = list(map(int,input().split()))
p.sort()
 
ans = p[n//2] - p[n//2-1]
print(ans)
import math

r = int(input())

#menseki
a = r*r*math.pi

#ensyu
b = 2*r*math.pi

print("%.5f %.5f" % (a, b))

### FIXED CODE ###

import math

r = float(float(input())) #??´??°??§?????????????????\???????????¨??? int?????????????????????????????????

#menseki
a = r*r*math.pi
 
#ensyu
b = 2*r*math.pi

print("%.6f %.6f" % (a, b))
number=list(map(int,input().split()))
n,m,x=number[0],number[1],number[2]
books=[list(map(int,input().split())) for i in range(n)]
U=[x for i in range(m+1)]
U[0]=0
pattern=[]
answer=[]


for i in range(2**n):
    tmp=[False]*n
    for j in range(n):
        if (i>>j)&1:
            tmp[j]=True
    
    pattern.append(tmp)

for i in range(2**n):
    cost=0
    U=[x for i in range(m+1)]
    U[0]=0
    for j in range(n):
        if pattern[i][j]==True:
            cost+=books[j][0]
            for k in range(1,m+1):
                U[k]-=books[j][k]
                if max(U)==0:
                    answer.append(cost)
                    break
                    
print(min(answer))
                

### FIXED CODE ###

number=list(map(int,input().split()))
n,m,x=number[0],number[1],number[2]
books=[list(map(int,input().split())) for i in range(n)]
U=[x for i in range(m+1)]
U[0]=0
pattern=[]
answer=[]


for i in range(2**n):
    tmp=[False]*n
    for j in range(n):
        if (i>>j)&1:
            tmp[j]=True
    
    pattern.append(tmp)

for i in range(2**n):
    cost=0
    U=[x for i in range(m+1)]
    U[0]=0
    for j in range(n):
        if pattern[i][j]==True:
            cost+=books[j][0]
            for k in range(1,m+1):
                U[k]-=books[j][k]
                if max(U)==0:
                    answer.append(cost)
                    break
                    
if answer==[]:
    print(-1)
else:
    print(min(answer))
import sys
input = sys.stdin.readline

X,Y,Z,K = (int(i) for i in input().split())
ax = [int(i) for i in input().split()]
by = [int(i) for i in input().split()]
cz = [int(i) for i in input().split()]
ans = [0] * (X*Y*Z)
cnt = 0
for i in ax:
  for j in by:
    for k in cz:
      ans[cnt] = i + j + k
      cnt += 1
ans.sort(reverse=True)
for i in range(K):
  print(ans[i])

### FIXED CODE ###

import heapq

X,Y,Z,K = (int(i) for i in 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()]
q = []
S = set()
a.sort()
b.sort()
c.sort()

heapq.heappush(q,(a[0]+b[0]+c[0],0,0,0))

for i in range(K):
  p,i,j,k=heapq.heappop(q)
  print(-p)
  if i+1 < X and not((i+1,j,k) in S):
    S.add((i+1,j,k))
    heapq.heappush(q,(a[i+1]+b[j]+c[k],i+1,j,k))
  if j+1 < Y and not((i,j+1,k) in S):
    S.add((i,j+1,k))
    heapq.heappush(q,(a[i]+b[j+1]+c[k],i,j+1,k))
  if k+1 < Z and not((i,j,k+1) in S):
    S.add((i,j,k+1))
    heapq.heappush(q,(a[i]+b[j]+c[k+1],i,j,k+1))
import itertools
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
A = [int(sys.stdin.readline()) for _ in range(N)]

a = list(itertools.accumulate(A, max))
b = list(itertools.accumulate(A[::-1], max))[::-1]

for i in range(len(A)):
    r = 0
    if 0 <= i - 1 < N:
        r = max(r, a[i - 1])
    if 0 <= i + 1 < N:
        r = max(r, b[i + 1])
    print(r)


### FIXED CODE ###

import itertools
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
A = [int(sys.stdin.readline()) for _ in range(N)]

a = list(itertools.accumulate(A, max))
b = list(itertools.accumulate(A[::-1], max))[::-1]

for i in range(len(A)):
    r = 0
    if 0 <= i - 1 < N:
        r = max(r, a[i - 1])
    if 0 <= i + 1 < N:
        r = max(r, b[i + 1])
    print(r)
import math


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


a, b, c, d = map(int, input().split())
e = b - int(b / c) - int(b / d) + int(b / lcm(c, d))
f = (a - 1) - int((a - 1) / c) - int((a - 1) / d) + int((a - 1) / lcm(c, d))
print(e - f)


### FIXED CODE ###

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


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


a, b, c, d = map(int, input().split())
a = a - 1
e = b - b // c - b // d + b // lcm(c, d)
f = a - a // c - a // d + a // lcm(c, d)
print(e - f)
a,c = map(int, input().split())
print(a*c*//2)

### FIXED CODE ###

a,b,c = map(int, input().split())
print(a*b//2)
a = str(input())

count = 0

for s in a:
  if int(s) == 1:
    count++
print(count)

### FIXED CODE ###

a = str(input())

count = 0

for s in a:
  if int(s) == 1:
    count+=1
print(count)
while True:
    st=[]
    n=input()
    if n=="":
      break
    st += n.lower()
    char = "abcdefghijklmnopqrstuvwxyz"

    for i in range(len(char)):
      print(char[i],":",st.count(char[i]))
    


### FIXED CODE ###

st=[]

while True:
  try:
    n=input()
    if n=="":
      break
    st += n.lower()
  except:
    break
   
char = "abcdefghijklmnopqrstuvwxyz"
for i in range(len(char)):
  print(char[i],":",st.count(char[i]))
# coding: utf-8

N = int(input())
S = input().rstrip('#')

lb = 0
rw = S.count('.')
ans = lb + rw

for i in range(N):
  if S[i] == '.':
    rw -= 1
  else:
    lb += 1
  ans = min(ans, rw + lb)

print(ans)

### FIXED CODE ###

# coding: utf-8

N = int(input())
S = input().rstrip('#')

lb = 0
rw = S.count('.')
ans = lb + rw

for i in range(len(S)):
  if S[i] == '.':
    rw -= 1
  else:
    lb += 1
  ans = min(ans, rw + lb)

print(ans)
n =list(map(int, input().strip()))
if 7 in n:
  print(‘Yes’)
else:
  print(‘No’)

### FIXED CODE ###

n =list(map(int, input().strip()))

if 7 in n:
  print('Yes')
else:
  print('No')
n=int(input())
button=[int(input()) for i in range(n)]
temp=1
ans=1
while button[temp-1] not in check:
  temp=button[temp-1]
  ans+=1
  if button[temp-1]==2:
    print(ans)
    break
  elif ans>=n:
    print(-1)
    break


### FIXED CODE ###

n=int(input())
button=[int(input()) for i in range(n)]
temp=1
ans=0
while True:
  temp=button[temp-1]
  ans+=1
  if temp==2:
    print(ans)
    break
  elif ans>=n:
    print(-1)
    break
def solve(n, y):
    for man in range(n + 1):
        for gosen in range(n - man + 1):
            sen = n - man - gosen
            if 10000*man + gosen*5000 + sen*1000 == y and man + gosen + sen == n:
                print('{} {} {}'.format(man, gosen, sen))
                return
    print("-1 -1 -1")
    return            

#main
n, y = map(int, raw_input().split())
solve(n, y)




### FIXED CODE ###

def solve(n, y):
    for man in range(n + 1):
        for gosen in range(n - man + 1):
            sen = n - man - gosen
            if 10000*man + gosen*5000 + sen*1000 == y and man + gosen + sen == n:
                print('{} {} {}'.format(man, gosen, sen))
                return
    print("-1 -1 -1")
    return            

#main
n, y = map(int, raw_input().split())
solve(n, y)
import sys
n = input()
a = list(map(int, input().split()))

if 0 in a:
  pirnt(0)
  sys.exit(0)

s = 1
for x in a:
  s *= x
  if s > 1000000000000000000:
    break
if s > 1000000000000000000:
  print(-1)
else:
  print(s)


### FIXED CODE ###

import sys

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

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

s = 1
for x in a:
  s *= x
  if s > 1000000000000000000:
    break
if s > 1000000000000000000:
  print(-1)
else:
  print(s)
N = int(input())
A = list(map(int, input().split()))
 
INF = 10**9
dp = [0] + [INF]*N
 
for i in range(1,N+1):
    if i == 1:
        dp[1] = abs(A[1]-A[0])
    else:
        dp[i] = min(dp[i-1]+abs(A[i]-A[i-1]), dp[i-2]+abs(A[i]-A[i-2]))
 
print(dp[N])

### FIXED CODE ###

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

INF = 10**9
dp = [INF]*N

def chmin(val1, val2):
    if val1 < val2:
        return val1
    else:
        return val2
        
for i in range(len(A)):
    if i == 0:
        dp[0] = 0
    elif i == 1:
        dp[1] = abs(A[1]-A[0])
    else:
        dp[i] = chmin(dp[i-1]+abs(A[i]-A[i-1]), dp[i-2]+abs(A[i]-A[i-2]))

print(dp[N-1])
N = int(input())

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

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

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

sum1 = sum(s1)

for i in range(N):
  if (s0[i]+1) == s0[i+1]:
    sum1 += s2[s0[i]-1]
  else :
    sum1=sum1

print(sum1)

### FIXED CODE ###

n = int(input())
print(n*n*n)
n, h, w = map(int, input().split())
tup_list = []
for i in range(n):
    tup_list.append((map(int, input().split())))
count = 0
for tuple in tup_list:
    if tuple[0] >= h and tuple[1] >= w:
        count += 1
print(count)


### FIXED CODE ###

nhw_list = list(map(int, input().split()))
tup_list = []
for i in range(nhw_list[0]):
    tup_list.append(list(map(int, input().split())))
count = 0
for tuple in tup_list:
    if tuple[0] >= nhw_list[1] and tuple[1] >= nhw_list[2]:
        count += 1
print(count)
import math

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

LCM = A[0]
for i in range(0,N-1,1):
    LCM = LCM*A[i+1]//math.gcd(A[i+1],LCM)
B = [0 for i in range(0,N,1)]
for i in range(0,N,1):
    B[i]= (LCM%MOD)*pow(A[i],MOD-2,MOD)%MOD

ans = 0
for i in range(0,N,1):
    ans = (B[i] + ans)%MOD

print(ans)

### FIXED CODE ###

def lcm(X,Y):
    x=X
    y=Y
    if y>x:
        x,y=y,x
    while x%y!=0:
        x,y=y,x%y
    return X*Y//y

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

LCM = A[0]
for i in range(0,N-1,1):
    LCM = lcm(LCM,A[i+1])
B = [0 for i in range(0,N,1)]
for i in range(0,N,1):
    B[i]= (LCM%MOD)*pow(A[i],MOD-2,MOD)%MOD

ans = 0
for i in range(0,N,1):
    ans = (B[i] + ans)%MOD

print(ans)
s = len(input())-2
print(f'i{s}n')

### FIXED CODE ###

s = input()
print(s[0]+str(len(s)-2)+s[-1])
table2 = {n:0 for n in "abcdefghijklmnopqrstuvwxyz"}
while True:
    x = input().lower()
    if x == "":
        break

    for i in x:
        if i in table2:
            table2[i] += 1

for m,n in table2.items():
    print("{0} : {1}".format(m,n))

### FIXED CODE ###

s=''
while True:
    try:
        s += input().lower()
    except:
        break
 
alph = "abcdefghijklmnopqrstuvwxyz"
 
for a in alph:
    print("{} : {}".format(a, s.count(a)))
from math import pow

def compute_score(target_collection):
    keys = {neta_point[0] for neta_point in target_collection}
    points = [neta_point[1] for neta_point in target_collection]
    cardinality = len(keys)
    score = pow(cardinality, 2) + sum(points)
    return score

# exchange one record and compare
def optimize(full_collection, target_collection, target_collection_len, idx):
    while True:
        ex_record = full_collection[idx]
        # check on the idx-th record
        idx += 1
        # bump up for return value
        if ex_record in target_collection:
            continue # cardinality score will not increase
        else:
            for i in range(target_collection_len-1):
                if target_collection[i][0] == target_collection[i-1][0]:
                    target_collection[i] = ex_record
                    new_score = compute_score(target_collection)
                    return new_score, target_collection, idx
        # default
        return 0, target_collection, idx



def cal_score(N, K, records):
    sorted_recs = sorted(records, reverse=True, key=lambda x: x[1])
    target_collection = sorted_recs[0:K]
    score =  compute_score(target_collection)

    # optimzie at most K times
    idx = K
    for i in range(K):
        new_score, new_target_collection, idx = optimize(sorted_recs, target_collection, K, idx)
        if new_score <= score: # no optimization occured
            break
        else:
            score = new_score
    return score
  
N, K = map(int, input().split())
records = [list(map(int, input().split())) for i in range(N)] 
score = cal_score(N, K, records)
print(score)


### FIXED CODE ###

from math import pow
from collections import deque, Counter
import sys
stdin = sys.stdin
def li(): return map(int, stdin.readline().split())

def cal_score(N, K, records):
    sorted_recs = sorted(records, key=lambda x: -x[1])
    target_queue = deque(sorted_recs[0:K]) # only allow pop() action, so use dequeue
    compare_queue = deque(sorted_recs[K:])
    distinct_set = set()
    dup_queue = deque()
    score = 0
    for neta_point in target_queue:
        score += neta_point[1]
        if neta_point[0] not in distinct_set:
            distinct_set.add(neta_point[0])
        else:
            dup_queue.append(neta_point)

    cardinality = len(distinct_set)
    score += pow(cardinality, 2)
    score = int(score)
    new_scores = deque()
    new_scores.append(score)
    # start iteration and comparing gain and lost
    while compare_queue:
        comp = compare_queue.popleft()
        if comp[0] in distinct_set:
            continue
        elif len(dup_queue) < 1:
            break
        else:
            old = dup_queue.pop()
            inc = 2 * len(distinct_set) + 1
            dec = old[1] - comp[1]
            delta = inc - dec
            new_score = new_scores[-1] + delta
            new_scores.append(new_score)

            distinct_set.add(comp[0])
    # both queues are drained
    return max(new_scores)

N, K = li()
records = [tuple(li()) for i in range(N)]
score = cal_score(N, K, records)
print(score)
n = input()
n_ichi = n % 10

if n_ichi == 3:
    print('bon')
elif n_ichi == 0 or n_ichi == 1 or n_ichi == 6 or n_ichi == 8:
    print('pon')
else:
    print('hon')

### FIXED CODE ###

n = input()
n_ichi = int(n) % 10
 
if n_ichi == 3:
    print('bon')
elif n_ichi == 0 or n_ichi == 1 or n_ichi == 6 or n_ichi == 8:
    print('pon')
else:
    print('hon')
n = int(input())
a = list(map(int,input().split()))

zero = 0
two = 0
odd = 0

for i in range(len(a)):
    if a[i] % 4 == 1 or a[i] % 4 == 3:
        odd = odd + 1
    elif a[i] % 4 == 0:
        zero = zero + 1
    else:
        two = two + 1
        
if zero >= odd -1 and two = 0:
    print('Yes')
elif zero >= odd:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

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

zero = 0
two = 0
odd = 0

for i in range(len(a)):
    if a[i] % 4 == 1 or a[i] % 4 == 3:
        odd = odd + 1
    elif a[i] % 4 == 0:
        zero = zero + 1
    else:
        two = two + 1
        
if zero >= odd -1 and two == 0:
    print('Yes')
elif zero >= odd:
    print('Yes')
else:
    print('No')
while True:
    try:
        a, b = map(int, raw_input().split())
        def gcd(a, b):
        if b == 0:
            return a
        else:
            return gcd(b, a%b)
        g = gcd(a,b)
        l = a*b/g
        print g, l
    except:
        break

### FIXED CODE ###

while True:
    try:
        a, b = map(int, raw_input().split())
        def gcd(a, b):
            if b == 0:
                return a
            else:
                return gcd(b, a%b)
        g = gcd(a,b)
        l = a*b/g
        print g, l
    except:
        break
import sys

N , M = map(int , input().split())
voyages = []
for i in range(M):
    voyages.append(list(map(int , input().split())))

def search(goal, path):
    n = path[len(path) - 1]
    if n == goal - 1:
        if len(path) < 4:
            print("POSSIBLE")
        else:
            print("IMPOSSIBLE")
        sys.exit()
        
    else:
        if n < len(voyages):
            for x in voyages[n]:
                if x not in path:
                    path.append(x)
                    search(goal, path)
                    path.pop()
        else:
            print("IMPOSSIBLE")
            sys.exit()
            
search(N, [0])

### FIXED CODE ###

N, M = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(M)]

toN = list(filter(lambda x: N in x, AB))
toN = set([flatten for inner in toN for flatten in inner])
frm_first = list(filter(lambda x: 1 in x, AB))
frm_first = set([flatten for inner in frm_first for flatten in inner])

if toN & frm_first:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
n = int(input())
s = input()
print(min(map(lambda x: x[0].count(
    "W") + x[1].count("E"),  [(s[:x], s[x+1:]) for x in range(n - 1)])))


### FIXED CODE ###

N = int(input())
S = input()
right = S[1:].count('E')
left = 0
answer = right
_reader = S[0]

for i in range(1, N):

    if _reader == "W":
        left += 1

    _reader = S[i]
    
    if _reader == "E":
        right -=1

    t = left + right
    answer = answer if answer <= t else t
        

print(answer)
N = int (input ())
S = str (input ())

def dot_num ():
    cnt = 0
    for i in range (N):
        if S [i] == '.':
            cnt += 1
    return cnt

def hash_num ():
    cnt = 0
    for i in range (N):
        if S [i] == '#':
            cnt += 1
    return cnt

dots = dot_num ()
hashes = hash_num ()

if S [0] == '.' and S [1] == '#':
    dots -= 1

if S [N-1] == '#' and S [N-2] == '.':
    hashes -= 1
    
print (min (dots, hashes))


### FIXED CODE ###

N = int (input ())
S = str (input ())
S = '.' + S
N += 1
cnt = 0
inf = int(1e9)

A = list(range(N))
for i in range(N):
    A[i] =[inf,inf]
A[0][0] = A[0][1] = 0
for i in range (1,N):
    for j in range (2):
        if j == 1:
            if S[i] == '.':
                A[i][j] = min(A[i][j], A[i-1][0] + 1)
                A[i][j] = min(A[i][j], A[i-1][1] + 1)
            else:
                A[i][j] = min(A[i][j], A[i-1][0] )
                A[i][j] = min(A[i][j], A[i-1][1] )
        else:
            if S[i] == '#':
                A[i][j] = min(A[i][j], A[i-1][0] + 1)
            else:
                A[i][j] = min(A[i][j], A[i-1][0])                

ans = min(A[N-1][0],A[N-1][1])

print (ans)
n,k = list(map(int, input().split()))
a=list(map(int, input().split()))

ans=[]
    


for i in range(1<<n):
    
    if bin(i).count("1")==k:
        cst=0
        use=a.copy()
        for u in range(1,n):
            if(i>>u&1):
                left_max=max(use[:u])
                cst+=left_max-use[u]+1
                use[u]= left_max+1
        ans.append(cst)   
print(min(ans))


### FIXED CODE ###

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

ans=[]
for i in range(1<<n):
    
    if bin(i).count("1")==k:
        cst=0
        use=a.copy()
        for u in range(1,n):
            if(i>>u&1):
                left_max=max(use[:u])
                cst+=left_max-use[u]+1 if left_max>=use[u] else 0
                use[u]= max(left_max+1, use[u])
        ans.append(cst)
print(min(ans))
N = int(input())
T = list(map(int, input().split()))
sumT = sum(T)
M = int(input())
PX = [list(map(int, input().split())) for _ in range(M)]
for i in range(M):
    print(sumT-T[i]+PX[i][1])

### FIXED CODE ###

N = int(input())
T = list(map(int, input().split()))
sumT = sum(T)
M = int(input())
PX = [list(map(int, input().split())) for _ in range(M)]
for i in range(M):
    p, x = PX[i]
    print(sumT-T[p-1]+x)
X,N = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]

if N != 0:
    sorted_p = sorted(p)
    flag = 0

    for x in range(N-1):
        diff = abs(X - sorted_p[x])
        if diff == 0:
            flag = 1
            break
        if diff <= abs(X-sorted_p[x+1]):
            break

    def checknum(d,loweridx,upperidx):
        upper = sorted_p[upperidx]
        lower = sorted_p[loweridx]
        if X-d == lower:
            if X+d == upper:
                if loweridx == 0:
                    print(X-d-1)
                elif upperidx == N-1:
                    print(X+d+1)
                else:
                    checknum(d+1,loweridx-1,upperidx+1)
            elif X-d == lower and X+d != upper:
                print(X+d)        
        else:
            return print(X-d)

    if not x in sorted_p:
        print(X)
    elif x == 0:
        print(X-1)
    elif x == N-1:
        a=1
        while(sorted_p[x-a] == X):
            a -= 1
        if sorted_p[x] != X-1:
            print(X-1)
        else:
            print(X+1)
    else:
        checknum(1,x-1,x+1)
else:
    print(X)

### FIXED CODE ###

X,N = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]

for d in range(X+1):
    for f in [-1,1]:
        a = X + d*f
        if p.count(a) == 0:
            print(a)
            exit()
X_string=input()
int=input(X_string)
if X>=30:
  print("Yes")
else:
  print("No")
  

### FIXED CODE ###

X_string=input()
X=int(X_string)
if X>=30:
  print("Yes")
else:
  print("No")
import copy

n = int(input())
t = list(map(int,input().split()))
m = int(input())
for i in range(m):
    p,x = map(int,input().split())
    l = t.copy()
    l[p-1] = x
    print(sum(l))

### FIXED CODE ###

import copy

n = int(input())
t = list(map(int,input().split()))
m = int(input())
for i in range(m):
    p,x = map(int,input().split())
    l = t.copy()
    l[p-1] = x
    print(sum(l))
from operator import itemgetter

N = int(input())
a = [0] * N
b = [0] * N
c = [0] *N


for i in range(N):
    a[i],b[i] = map(int,input().split())
    c[i] = [b[i],a[i]]
   
c.sort()
sums = 0
correct = 1
for i in range(N):
    sums+=c[i][0]
    if b[i][1] >sums:
        correct=0
        break

if correct:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

from operator import itemgetter

N = int(input())
a = [0] * N
b = [0] * N
c = [0] *N


for i in range(N):
    a[i],b[i] = map(int,input().split())
    c[i] = [b[i],a[i]]
   
c.sort()
sums = 0
correct = 1
for i in range(N):
    sums+=c[i][1]
    if c[i][0] < sums:
        correct=0
        break
        
if correct:
    print("Yes")
else:
    print("No")
N, M = map(int, input().split())
G = [[] for _ in range(M)]
res = [""] * M
for i in range(M):
    p, y = map(int, input().split())
    G[p - 1].append((y, i))

G = list(map(sorted, G))
for p in range(N):
    for m, (y, i) in enumerate(G[p], 1):
        res[i] = 10 ** 12 + (p + 1) * 10 ** 6 + m

for r in res:
    print(str(r)[1:])

### FIXED CODE ###

N, M = map(int, input().split())
G = [[] for _ in range(N)]
res = [""] * M
for i in range(M):
    p, y = map(int, input().split())
    G[p - 1].append((y, i))

G = list(map(sorted, G))
for p in range(N):
    for m, (y, i) in enumerate(G[p], 1):
        res[i] = 10 ** 12 + (p + 1) * 10 ** 6 + m

for r in res:
    print(str(r)[1:])
while 1:
    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    col1 = "#." * (W + 1) // 2
    col2 = ".#" * (W + 1) // 2
    print((col1[:W] + "\n" + col2[:W] + "\n") * (H // 2) + (col1[:W] + "\n") * H % 2)

### FIXED CODE ###

while 1:
    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    col1 = "#." * ((W + 1) // 2)
    col2 = ".#" * ((W + 1) // 2)
    print((col1[:W] + "\n" + col2[:W] + "\n") * (H // 2) + (col1[:W] + "\n") * (H % 2))