Harryxun/stf_run huggingface dataset:
R, C, N = map(int, raw_input().split())

lines = []
for i in range(N):
	x, y, xx, yy = map(int, raw_input().split())
	if (x in [0, R] or y in [0, C]) and (xx in [0, R] or yy in [0, C]):
		if x <= y:
			first = x+y
		else:
			first = (R*2 + C*2)-(x+y)
		if xx <= yy:
			second = xx+yy
		else:
			second = (R*2 + C*2)-(xx+yy)
		new_line = [first, second] if first < second else [second, first]
		j = 0
		for j in range(len(lines)):
			if new_line[0] < lines[j][0]:
				lines.insert(j, new_line)
				break
		else:
			lines.append(new_line)

false_flag = False
scopes = []
scopes.append(lines.pop(0))
while lines and not false_flag:
	while scopes:
		next_scope = lines.pop(0)
		right = scopes[-1][1]
		next_left = next_scope[0]
		next_right = next_scope[1]
		if next_left < right:
			if next_right < right:
				if lines:
					scopes.append(next_scope)
				else:
					break
			else:
				false_flag = True
				break
		else:
			scopes.pop()
	else:
		scopes.append(next_scope)

if false_flag:
	print 'NO'
else:
	print 'YES'

### FIXED CODE ###

MOD = pow(10, 9)+7
N, M = map(int, raw_input().split())

def myfact(num):
	res = 1
	for i in range(num+1)[1:]:
		res *= i
		if res > MOD:
			res %= MOD
	return res
if abs(N - M) > 1:
	print 0
else:
	if N == M:

		res = ( myfact(N) * myfact(N) * 2 )%MOD
	else:
		res = ( myfact(N) * myfact(M) )%MOD
	print res
H, W, N = map(int, input().split())
Grid = [[0]*(W-2) for _ in range(H-2)] #3*3正方形を左上のマスで区別。値は正方形内の黒塗りの個数
Ans = [(H-2)*(W-2) if i == 0 else 0 for i in range(10)] 
f = lambda x:int(x)-1
Draw = lambda x,y:[(x-i,y-j) for i in range(3) for j in range(3) if 0<=x-i<H-2 and 0<=y-j<W-2] #塗りつぶしたマスを含む正方形の座標のリストを返す関数
for _ in range(N):
    a, b = map(f, input().split())
    for x,y in Draw(a,b): #Ans及びGridの更新
        Ans[Grid[x][y]] += -1
        Ans[Grid[x][y]+1] += 1
        Grid[x][y] += 1
for ans in Ans:print(ans)

### FIXED CODE ###

H, W, N = map(int, input().split())
from collections import defaultdict as dd
Grid =  dd(lambda:0) #3*3正方形を左上のマスで区別。値は正方形内の黒塗りの個数
Draw = lambda x,y:[(x-i,y-j) for i in range(3) for j in range(3) if 0<=x-i<H-2 and 0<=y-j<W-2] #塗りつぶしたマスを含む正方形の座標のリストを返す関数
for _ in range(N):
    a, b = map(int, input().split())
    for x,y in Draw(a-1,b-1): #Gridの更新
        Grid[x,y] += 1
Ans = [(H-2)*(W-2)-len(Grid) if i == 0 else sum(v==i for v in Grid.values()) for i in range(10)]         
for ans in Ans:
    print(ans)
n = input()

if n % 2 == 0:
  print(n // 2)
else:
  print(n // 2 + 1)

### FIXED CODE ###

n = int(input())

if n % 2 == 0:
  print(n // 2)
else:
  print(n // 2 + 1)
def get_answer():
  x = int(input())
  
  is_get = False
  for a in range(1000000000):
    if is_get:
      break
    for b in range(-1*a, a, 1):
      if x == a**5 - b**5:
        is_get = True
        break
        
  print(f"{a-1} {b}")

if __name__ = "__main__":
  get_answer()

### FIXED CODE ###

def get_answer():
  x = int(input())
  
  is_get = False
  for a in range(1000000000):
    if is_get:
      break
    for b in range(-1*a, a, 1):
      if x == a**5 - b**5:
        is_get = True
        break
        
  print(f"{a-1} {b}")

if __name__ == "__main__":
  get_answer()
from collections import defaultdict
N,P = map(int, input().split())
is_prime = [True]*(10**6+1)
is_prime[0] = is_prime[1] = False
def sieve(n:int):
    """Sieve of Eratoshenes
    return the number of prime number (0, n]"""
    global is_prime
    for i in range(2, n+1):
        if is_prime[i]:
            # 素数の倍数は合成数
            for j in range(i*2, n+1, i):
                is_prime[j] = False

sieve(10**6)
facts = defaultdict(lambda:0)
p = P
for i in range(P):
    if not is_prime[i]:
        continue
    if p == 1:
        break
    while p % i == 0:
        p //= i
        facts[i] += 1
ans = 1
for k,v in facts.items():
    ans *= pow(k, v//N)
print(ans)


### FIXED CODE ###

from collections import defaultdict
from math import sqrt
N,P = map(int, input().split())
is_prime = [True]*(10**6+1)
is_prime[0] = is_prime[1] = False
def sieve(n:int):
    """Sieve of Eratoshenes
    return the number of prime number (0, n]"""
    global is_prime
    for i in range(2, n+1):
        if is_prime[i]:
            # 素数の倍数は合成数
            for j in range(i*2, n+1, i):
                is_prime[j] = False

sieve(10**6)
facts = defaultdict(lambda:0)
p = P
for i in range(int(sqrt(P))):
    if not is_prime[i]:
        continue
    if p == 1:
        break
    while p % i == 0:
        p //= i
        facts[i] += 1
if p>0:
    facts[p] += 1
ans = 1
for k,v in facts.items():
    ans *= pow(k, v//N)
print(ans)
import bisect
n = int(input())
c = [int(input()) for i in range(n)]

ans = 1
li = [[] for i in range(9)]
for i in range(n):
  if not li[c[i]]:
    li[c[i]].append(i)
  else:
#    if li[c[i]] != li[c[i]][-1]

    li[c[i]].append(i)
    ans += len(li[c[i]]) - 1
#    for j in range(9):
#      ans += len()-1
#      bisect.bisect_left(li[i],)
print(ans)

### FIXED CODE ###

n = int(input())
cc = [int(input()) for i in range(n)]
c = [cc[0]]
for i in range(1,n):
  if cc[i] != cc[i-1]:
    c.append(cc[i])

n = len(c)
dp = [0 for i in range(n)]
pos_dp = [-1 for i in range(2*10**5+1)]

dp[0] = 1
pos_dp[c[0]] = 0
     
for i in range(1,n):
  if pos_dp[c[i]]!=-1:
    dp[i] = (dp[i-1] + dp[pos_dp[c[i]]])%1000000007
  else:
    dp[i] = dp[i-1] 
  pos_dp[c[i]] = i

print(dp[n-1])
x = int(raw_input())
y = x * x * x
print "{0}" .format(y)

### FIXED CODE ###

n=int(input())**3
print("{0}".format(n))
a,b,x,y = input().rstrip().split(' ')
r = 0
if x + x == a and y + y == b:
    r = 1
print(a*b/2,r)

### FIXED CODE ###

a,b,x,y = map(int,input().rstrip().split(' '))
r = 0
if x + x == a and y + y == b:
    r = 1
print(a*b/2,r)
s=list(map(str,input().split()))
a=0
for i in s:
  if i in ATGC:
    a+=1
  else:
    b=a
    a=0
print(max(a,b))

### FIXED CODE ###

s=input()
a=0
b=0
for i in s:
  if i in "ATGC" :
    a+=1
  else:
    b=max(a,b)
    a=0
print(max(a,b))
N=int(input())
A=[int(i) for i in input().split()]
A.sort()
miss=0
if N%2==0:
    for i in range(int(N/2)):
        if miss==1:
            break
        for j in range(2):
            if A[0]==2*i+1:
                A.pop(0)
            else:
                miss=1
                break
    if miss==1:
        print(0)
    else:
        print(int((2**int(N/2))%(10e9+7)))

if N%2==1:
    if not 0 in A:
        miss=1
    else:
        A.pop(0)
    for i in range(int((N-1)/2)):
        if miss==1:
            break
        for j in range(2):
            if A[0]==2*i+2:
                A.pop(0)
            else:
                miss=1
                break
    if miss==1:
        print(0)
    else:
        print(int((2**int((N-1)/2))%(10e9+7)))

### FIXED CODE ###

N=int(input())
A=[int(i) for i in input().split()]
A.sort()
miss=0

if N%2==0:
    for i in range(int(N/2)):    
        if miss==1:
            break
        for j in range(2):
            if A[0]==2*i+1:
                A.pop(0)
            else:
                miss=1
                break
                
    if miss==1:
        print(0)
    else:
        print(int((2**int(N/2))%(10**9+7)))

else:
    if A[0]!=0:
        miss=1
        A.pop(0)
    else:
        A.pop(0)
    for i in range(int((N-1)/2)):
        if miss==1:
            break
        for j in range(2):
            if A[0]==2*i+2:
                A.pop(0)
            else:
                miss=1
                break
                
    if miss==1:
        print(0)
    else:
        print(int((2**int((N-1)/2))%(10**9+7)))
x = int(input())
n = x
while True:
  isPrime = True
  for i in range(2, int(sqrt(n))):
    if n % i == 0:
      isPrime = False
      break
  if isPrime:
    print(n)
    break
  if n % 2 == 0:
    n += 1
  else:
    n += 2

### FIXED CODE ###

import math
x = int(input())
n = x
while True:
  isPrime = True
  for i in range(2, int(math.sqrt(n))):
    if n % i == 0:
      isPrime = False
      break
  if isPrime:
    print(n)
    break
  n += 1
def fetch_one_line():
    return stdin.readline().rstrip()
  
def fetch_int_input():
    return [int(s) for s in fetch_one_line().split()]
  
K, X = fetch_one_line()

answer = ["Yes", "No"]
print(answer[int(500 * K >= X)])

### FIXED CODE ###

from sys import stdin

def fetch_one_line():
    return stdin.readline().rstrip()
  
def fetch_int_input():
    return [int(s) for s in fetch_one_line().split()]
  
K, X = fetch_int_input()

answer = ["No", "Yes"]
print(answer[int(500 * K >= X)])
from scipy.special import comb

N = int(input())
ss = []
for i in range(N):
	ss.append("".join(sorted(list(input()))))
	
dicS = {}
for s in ss:
	if s not in dicS:
		dicS[s] = 1
	else:
		dicS[s] += 1
		
ans = 0
for v in dicS.values():
	ans += comb(v, 2, exact=True)
	
print(ans)

### FIXED CODE ###

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
    
    
N = int(input())
ss = []
for i in range(N):
	ss.append("".join(sorted(list(input()))))
	
dicS = {}
for s in ss:
	if s not in dicS:
		dicS[s] = 1
	else:
		dicS[s] += 1
		
#print(dicS)
		
ans = 0
for v in dicS.values():
	if v != 1:
		ans += cmb(v, 2)
	
print(ans)
strings = input().split(' ')
A = int(strings[0])
B = int(strings[1])

i = min(A,B)
m = A
n = B
while max(m,n) % min(n,m) != 0:
    mt = max(m,n) // min(m,n)
    nt = max(m,n) % min(m,n)
    m = mt
    n = nt
    gmc = max(m,n) // min(n,m)

At = A // gmc
Bt = B // gmc
print(gmc * At * Bt)
    

### FIXED CODE ###

strings = input().split(' ')
A = int(strings[0])
B = int(strings[1])

i = min(A,B)
m = max(A,B)
n = min(A,B)
while 1:
    mt = n
    n = m % n
    m = mt
    if n == 0:
        break
if m != 0:
    print(A*B//m)
else:
    print(A*B)
n = int(input())
x = [input().split() for i in range(n)]
ans = 0.0
for row in x:
  if row[1] == 'JPY':
    ans += float(row[0])
  else:
    ans += float(row[1]) * 380000
print(ans)

### FIXED CODE ###

n = int(input())
x = [input().split() for i in range(n)]
ans = 0.0
for row in x:
  if row[1] == 'JPY':
    ans += float(row[0])
  else:
    ans += float(row[0]) * 380000
print(ans)
import math
n, k = map(int, input().split())
h = list(map(int, input().split()))

def frog(n, k, h):
    d = [math.inf] * n
    d[0] = 0
    
    for i in range(1, n):
        
        d[i] = min(d[j] + abs(h[i] - h[j]) for j in range(max(i-k, 0), i))
    return d[n-1]
    
print(frog(n, k, h))

### FIXED CODE ###

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

def frog(n, k, h):
    import math
    d = [float('inf')] * n
    d[0] = 0
    
    for i in range(1, n):
        
        d[i] = min(d[j] + abs(h[i] - h[j]) for j in range(max(i-k, 0), i))
    return d[n-1]
    
print(frog(n, k, h))
N, X = map(lambda x: int(x), input().split())[:2]
L = map(lambda x: int(x), input().split())
D = 0
count = 0
for l in L:
  if D <= X:
      count += 1
  D += l
print(count)

### FIXED CODE ###

N, X = map(int, input().split())
L = map(int, input().split())
D = 0
count = 1
for i, l in enumerate(L):
  D += l
  if D <= X:
      count += 1
print(count)
n,m=int(intput().split())
print((n-1)*(m-1))

### FIXED CODE ###

n,m=map(int,input().split())
print((n-1)*(m-1))
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

dish = [a,b,c,d,e]
result=0

mx=-1

for dd in dish:
    for i in range(1,10):
        if (dd+i) % 10 == 0:
            tmp=i
            break
    if tmp > mx:
        mx = tmp
        buf=dd

dish.remove(buf)

for i in range(4):
    result+=dish[i]
    for j in range(1,10):
        if result % 10 ==0:
            break
        result+=1

print(result+buf)

### FIXED CODE ###

a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

dish = [a,b,c,d,e]
result=0

mx=-1

for dd in dish:
    for i in range(0,10):
        if (dd+i) % 10 == 0:
            tmp=i
            break
    if tmp > mx:
        mx = tmp
        buf=dd

dish.remove(buf)

for dd in dish:
    result+=dd
    for i in range(1,10):
        if result % 10 == 0:
            break
        result+=1
        
print(result+buf)
S = input()
T = input()

for i in range(0,len(S)):
	if S[i] == T[-i]:
		continue
	else:
		print('No')
		return

print('Yes')


### FIXED CODE ###

S = input()
T = input()

for i in range(0,len(S)):
    if S == T:
        print('Yes')
        break
    else:
        T = T[len(T)-1]+T[0:len(T)-1]
else:
    print('No')
#coding: utf-8

if __name__=="__main__":
    a, b = list(map(int, input().replace("\n","").split(" ")))
    if(a > b):
	print("Alice")
    elif(a == b):
	print("Draw")
    else:
	print("Bob")


### FIXED CODE ###

if __name__=="__main__":
    a, b = list(map(int, input().split(" ")))
    if(a==1):
        a = 14
    if(b==1):
        b = 14
    if(a > b):
        print("Alice")
    elif(a == b):
        print("Draw")
    else:
        print("Bob")
S=int(input())
MON=6
TUE=5
WED=4
THU=3
FRI=2
SAT=1
SUN=0
print(7-S)

### FIXED CODE ###

S = input()
if S == "MON":
    print(6)
elif S == "TUE":
    print(5)
elif S == "WED":
    print(4)
elif S == "THU":
    print(3)
elif S == "FRI":
    print(2)
elif S == "SAT":
    print(1)
else :
    print(7)
N=int(input())
S=input()
S_list=list(S)
S_max=0
for n in range(N):
    S_list_former=set(S_list[:n])
    S_list_latter=set(S_list[n:N])
    S_list_com=len(S_list_former & S_list_latter)
    if S_list_com>=S_max:
        S_max=S_list_com
print(S_max)

### FIXED CODE ###

a,b=map(int, input().split())
ab_sum=a+b
ab_dif=a-b
ab_pro=a*b
ab_max=max(ab_sum,ab_dif,ab_pro)
print(ab_max)
# ABC 167 C
N,M,X = map(int,input().split())
C =[]
for m in range(N):
    C.append([int(i) for i in input().split()])
C.sort(key=lambda x:x[0])

from itertools import combinations
import numpy as np

ans = 10**5 +1

for m in range(1,M+1):
    P=list(combinations(C,m))
    tmp =np.sum(P,axis=1)
    if ans < tmp[0,0]:
        print(ans)
        exit()
    elif min(tmp[0,1:])>=X and ans > tmp[0,0]:
        ans = tmp[0,0]


if min(tmp[0,1:])<X:
    print(-1)
else:
    print(ans)


### FIXED CODE ###

N,M,X =map(int,input().split())
A =[]
for m in range(N):
    A.append([int(j) for j in input().split()])
ans = 10**10
import numpy as np
from itertools import product,compress
for i in list(product([True,False],repeat=N)):
    tmp = np.sum(list(compress(A, i)),axis=0)
    if type(tmp)!=np.float64:
    	if tmp[0]< ans and min(tmp[1:])>=X:
            ans =tmp[0]
if ans ==10**10:
    print(-1)
else:
    print(ans)
mod0 = []
lst = []
for i in range(5):
    inp = int(input())
    if inp % 10 == 0:
        mod0.append(inp)
    else:
        lst.append(inp)

ans = sum(mod0)
last = 0
for n, i in enumerate(lst):
    for nn, ii in enumerate(lst):
        if i % 10 < ii % 10:
            last = i
        else:
            last = ii

for i, ii in enumerate(lst):
    if ii == last:
        continue
    ans += (ii // 10 + 1) * 10

print(ans+last)


### FIXED CODE ###

mod0 = []
lst = []
for i in range(5):
    inp = int(input())
    if inp % 10 == 0:
        mod0.append(inp)
    else:
        lst.append([inp, inp % 10])
ans = sum(mod0)
lst.sort(key= lambda x :x[1])

if len(lst) != 0:
    last = lst.pop(0)
    ans = sum(mod0)
    for i,imod in lst:
        ans += (i//10 +1)*10
    ans+=last[0]

print(ans)
A = input()
A =int(A)
P = input()
P =int(P)

print ( (A * 3 + P) // 2 )

### FIXED CODE ###

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



a=((P + A * 3) / 2)
print(int(a))
x = int(input())
tmp = x%100

if x % tmp == 0:
    print(1)
else:
    print(0)


### FIXED CODE ###

x = int(input())
flag = False

for i in range(1,2000):
    if i * 100 <= x <= i * 105:
        flag = True
        break

if flag:
    print(1)
else:
    print(0)
import fractions
import math
n,m = map(int,input().split())
a = list(map(int, input().split()))
g = a[0]
for i in a:
    g = g * i // fractions.gcd(g,i)
if g/2 > m:
    print(0)
else:
    print((m + g // 2) // g)

### FIXED CODE ###

import fractions
import math
n,m = map(int,input().split())
a = list(map(int, input().split()))
s = set(a)
c = set()
l = 1
k = (a[0] // 2) % 2
for i in a:
    l = l * i // fractions.gcd(l,i)
    if l // 2 > m:
        ans = 0
        break
    count = 0
    while True:
        if (i>>count) % 2 == 0:
            count += 1
        else:
            c.add(count)
            break
    if len(c) > 1:
        ans = 0
        break
else:
    ans = (m + l // 2) // l

print(ans)
X,Y=map(int,input().split())
dev = int(Y/X)
work = 1
for i in range(108):
  tmp = pow(2,i)
  if tmp <= dev and dev < tmp*2:
    work +=i
    break
print(work)

### FIXED CODE ###

A,B,C,D=map(int,input().split())
if A+B==C+D:
  print('Balanced')
elif A+B>C+D:
  print('Left')
else:
  print('Right')
A, B = map(int, input().rstrip().split(' '))
values = list(range(A, B + 1))
#xor_bit = [0] * (B - A)

xor = 0
digit = 0
while True:
    if values[-1] == 0:
        break
    
    num_zeros = 0
    for v in values:
        if v == 0:
            num_zeros = 0
        else:
            break
    
    values = values[num_zeros:]
    
    num_one = 0
    for i, v in enumerate(values):
        num_one += v % 2
        values[i] = v // 2
      
    xor += 2 ** digit * (num_one % 2)
    
    digit += 1
    
print(xor)
    

### FIXED CODE ###

# coding: utf-8
# Your code here!

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

if A == B:
    print(A)
    
else:
    max_bit = 0
    copied_B = B
    while copied_B > 0:
        copied_B = copied_B // 2
        max_bit += 1
    
    count = 0
    for digit in range(max_bit):
        period = 2 ** (digit + 1)
        pos_A = A % period
        pos_B = B % period
        
        num_one = 0
        if pos_A >= period // 2:
            num_one += period - pos_A
        else:
            num_one += period // 2
         
        if pos_B >= period // 2:
            num_one += pos_B - period // 2 + 1
            
        if digit == 0:
            num_one = 0
            num_one += B % 2
            num_one += A % 2
            if B % 2 == 1 and A % 2 == 1:
                num_one += (B - A - 1) // 2
            else:
                num_one += (B - A) // 2
            
        if num_one % 2 != 0:
            count += 2 ** digit
         
    print(count)
n1 = set([1, 3, 5, 7, 8, 10, 12])
n2 = set([4, 6, 9, 11])
n3 = set([2])
nums = set(map(int, input().split())
print("Yes" if nums <= n1 or nums <= n2 or nums <= n3 else "No")
  

### FIXED CODE ###

n1 = [1, 3, 5, 7, 8, 10, 12]
n2 = [4, 6, 9, 11]

a, b = map(int, input().split())
print("Yes" if a in n1 and b in n1 or a in n2 and b in n2 else "No")
N, M = map(int, input().split())
G = [[] for _ in range(N)]
for i in range(M):
  a, b = map(lambda x: int(x)-1, input().split())
  G[a].append(b)

for v in G[0]:
  if nv in G[v]:
    print("POSSIBLE")
    exit()
print("IMPOSSIBLE")


### FIXED CODE ###

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

for i in range(M):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  edges[a].append(b)

for i in edges[0]:
  if N-1 in edges[i]:
    print("POSSIBLE")
    exit()
print("IMPOSSIBLE")
import numpy as np
import sys

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

def calcs(val, han):
    if val < han:
        am = han
    else:
        am = zen-(val)
    return am

def calce(val, han):
    if val < han:
        am = han
    else:
        am = zen-(val+1)
    return am


L = int(np.ceil(np.log2(B)))
result = 0
for i in range(L+1):
    am = 0

    zen = 2**(i+1)
    han = zen//2
    # if i==0:
        # b = (B-A)%2
    # else:
    b = (calcs(A%zen, han) + calce(B%zen, han))%2

    # print(i, zen, han , "  |  ", A%zen, calcs(A%zen, han), "  |  ", B%zen, calce(B%zen, han))
    # print(b)

    result += han*b

print(result)

### FIXED CODE ###

import numpy as np
import sys

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

def f(x):
    if x%4 == 0:
        return x
    elif x%4 == 1:
        return x^(x-1)
    elif x%4 == 2:
        return x^1
    else:
        return x^(x-1)^1

print(f(A-1)^f(B))
a,b = map(int,input().split())

c = list(map(int,input().split()))
c.sort()

d = []
for i in range(b-1):
    d.append(c[i+1] - c[i])

d.sort()

#print(c,d)

for k in range(a - 1):
    d.pop()

print(sum(d))

### FIXED CODE ###

# coding: utf-8
# Your code here!
a = list(map(int,input().split()))
b = list(map(int,input().split()))
b.sort()

c = []
if len(b) != 1:
  for i in range(len(b) - 1):
    c.append(b[i+1] - b[i])

if len(b) == 1:
  print(0)
  
    
else:  
  c.sort()
  for j in range(min(a[0] - 1,a[1])):
    c[len(c)- 1 - j] = 0
  print(sum(c))
A,B,C=(int(x) for x in input().split())
if B is "+":
    n = int(A) + int(C)
    print(n)
elif B is "-":
    n = int(A) - int(C)
    print(n)

### FIXED CODE ###

A,B,C = input().split()
if B is "+":
    n = int(A) + int(C)
    print(n)
elif B is "-":
    n = int(A) - int(C)
    print(n)
N = input()
K = input()

for i in range(N):
  list.append(input())

list.sort()

for j in range(K):
  A += list[j]

print(A)

### FIXED CODE ###

N,K = input().split()
lists = []
B = 0

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

lists.sort()
#print(lists)

for j in range(int(K)):
  B += int(lists[j])
 
print(B)
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()))

AB=[0]*(x*y)
i=0
for a in A:
    for b in B:
        AB[i]=a+b
        i+=1

AB=AB.sort(reverse=True)[:min(k,x*y)]
ABC=[0]*(min(k,x*y)*z)
i=0
for ab in AB:
    for c in C:
        ABC[i]=ab+c
        i+=1

ABC.sort(reverse=True)

for i in range(k):
    print(ABC[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(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)


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

ABC=[ab+c for ab in AB[:min(k,x*y)] for c in C]
ABC.sort(reverse=True)

for i in range(k):
    print(ABC[i])
n,C=map(int,input().split())
dp=[[0 for i in range(100001)] for j in range(31)]
for i in range(n):
  s,t,c=map(int,input().split())
  t+=1
  dp[c][s]+=1
  dp[c][t]-=1
nm=[0 for i in range(100001)]
for i in range(31):
  s=1
  for j in range(1,100001):
    dp[i][j]+=dp[i][j-1]
    if dp[i][j]==0 and dp[i][j-1]==1:
      nm[s]+=1
      nm[j]-=1
    elif dp[i][j]==1 and dp[i][j-1]==0:
      s=j
for i in range(1,100001):
  nm[i]+=nm[i-1]
print(max(nm))

### FIXED CODE ###

n,C=map(int,input().split())
dp=[[0 for i in range(100002)] for j in range(31)]
for i in range(n):
  s,t,c=map(int,input().split())
  t+=1
  dp[c][s]+=1
  dp[c][t]-=1
nm=[0 for i in range(100002)]
for i in range(31):
  s=1
  for j in range(1,100002):
    dp[i][j]+=dp[i][j-1]
    if dp[i][j]==0 and dp[i][j-1]==1:
      nm[s]+=1
      nm[j]-=1
    elif dp[i][j]==1 and dp[i][j-1]==0:
      s=j
for i in range(1,100002):
  nm[i]+=nm[i-1]
print(max(nm))
N,K = map(int,input().split())
A = [int(input()) for _ in range(N)]
dp2 = [0] * N
for i in range(N):
    tmax = 0
    for j in range(i+1):
        if abs(A[i]-A[j]) <= K:
            tmax = max(tmax,dp2[j]+1)
    dp2[i] = tmax  

print(max(dp2))

### FIXED CODE ###

K = int(input())
print("ACL" * K)
def OorC():
    if (T in lst) == True:
        if lst2[lst.index(T)] % 2 == 0:
            lst2[lst.index(T)] += 1
            print "Opened by " + T
        else:
            lst2[lst.index(T)] += 1
            print "Closed by " + T
    else:
        print "Unknown " + T
        

while 1:
    N = int(input())
    lst = []
    lst2 = []
    for i in range(N):
        lst.append(str(raw_input()))
        lst2.append(0)
    M = int(input())
    for j in range(M):
        T = str(raw_input())
        OorC()

### FIXED CODE ###

N = int(input())
a = 0
lst = []
for i in range(N):
    lst.append(str(raw_input()))
M = int(input())
for j in range(M):
    T = str(raw_input())
    if (T in lst) == True:
        if a == 0:
            a = 1
            print "Opened by " + T
        else:
            a = 0
            print "Closed by " + T
    else:
        print "Unknown " + T