Harryxun/stf_run huggingface dataset:
def answer(n, m, taro, hanako):
    for t in sorted(taro):
        for h in sorted(hanako):
            if sum(taro) - t + h == sum(hanako) - h + t:
                return '{t} {h}'
    return -1

while True:
    n, m = map(int, input().split())
    if n == 0 and m == 0:
        break
    taro = []
    hanako = []
    for i in range(n)
        taro.append(int(input()))
    for i in range(m)
        hanako.append(int(input()))
    print(answer(n, m, taro, hanako))


### FIXED CODE ###

def answer(n, m, taro, hanako):
    for t in sorted(taro):
        for h in sorted(hanako):
            if sum(taro) - t + h == sum(hanako) - h + t:
                return f'{t} {h}'
    return -1


while True:
    n, m = map(int, input().split()) # 組み込み関数input()は標準入力から読み込まれた1行を返す．
    if n == 0 and m == 0:
        break
    taro = []
    hanako = []
    for i in range(n):
        taro.append(int(input()))
    for i in range(m):
        hanako.append(int(input()))
    print(answer(n, m, taro, hanako))
import sys


def main():
    a, b = [int(s) for s in sys.stdin.readline().strip().split()]

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

    def divisors(n, d, ans):
        if n == 1:
            return
        if d > n:
            return
        if n % d == 0:
            ans.append(d)
            divisors(n // d, d, ans)
        else:
            divisors(n, d+1, ans)

    gcd_val = gcd(a, b)
    divs = []
    divisors(gcd_val, 2, divs)
    ans = 1
    for div in sorted(divs):
        if div == 1:
            continue
        if gcd_val % div == 0:
            ans += 1
            while gcd_val % div == 0 and gcd_val > 1:
                gcd_val = gcd_val // div
    print(ans)


main()


### FIXED CODE ###

import sys
import math

def main():
    a, b = [int(s) for s in sys.stdin.readline().strip().split()]

    def factorize(x):
        ret = set()
        for n in range(2, int(math.sqrt(x))+2):
            if x % n == 0:
                while x % n == 0:
                    x //= n
                ret.add(n)
        if x != 1:
            ret.add(x)
        return ret

    a_primes = factorize(a)
    b_primes = factorize(b)
    shared = a_primes.intersection(b_primes)
    print(len(shared) + 1)


main()
N = int(input())
X = input()
bin_X = int(X, 2)
cnt = 0
for i in X:
    if i == '1':
        cnt += 1

def bit_count(bits):
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555)
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333)
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f)
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff)
    return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff)


def pop_counter(n):
    return n % bit_count(n)


ans = 0
for n, i in enumerate(X):
    ans = 1
    tmp = bin_X ^ pow(2, N - n - 1)
    if i == '1':
        tmp %= cnt - 1
    else:
        tmp %= cnt + 1
    while tmp != 0:
        tmp = pop_counter(tmp)
        ans += 1
    print(ans)


### FIXED CODE ###

N = int(input())
X = input()
bin_X = int(X, 2)
cnt = 0
for i in X:
    if i == '1':
        cnt += 1


def bit_count(bits):
    cnt = 0
    while bits:
        bits = bits & (bits - 1)
        bits >> 1
        cnt += 1
    return cnt


def pop_counter(n):
    return n % bit_count(n)


ans = 0
xp = bin_X % (cnt + 1)
if cnt != 1:
    xm = bin_X % (cnt - 1)
else:
    xm = 0
for n, i in enumerate(X):
    if i == '0':
        tmp = xp + pow(2, N - n - 1, cnt + 1)
        tmp %= cnt + 1
    elif cnt != 1:
        tmp = xm - pow(2,N-n-1,cnt-1)
        tmp %= cnt -1
    else:
        print(0)
        continue
    ans = 1
    while tmp != 0:
        tmp = pop_counter(tmp)
        ans += 1
    print(ans)
N = int(input())
W = list(map(int, input().split()))

diff = np.abs(np.sum(W[0]) - np.sum(W[0:]))
for i in range(N):
    S_1 = np.sum(W[:i])
    S_2 = np.sum(W[i:])
    diff = np.abs(S_1 - S_2)
    if S_1 > S_2:
        if diff > np.abs(S_1 - S_2):
            print(np.abs(S_1 - S_2))
        else:
            print(diff)
        break
    elif S_1 == S_2:
        print(0)



### FIXED CODE ###

import numpy as np

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

diff = np.abs(np.sum(W[0]) - np.sum(W[0:]))
for i in range(N):
    S_1 = np.sum(W[:i])
    S_2 = np.sum(W[i:])
    if S_1 > S_2:
        if diff > np.abs(S_1 - S_2):
            print(np.abs(S_1 - S_2))
        else:
            print(diff)
        break
    elif S_1 == S_2:
        print(0)
    diff = np.abs(S_1 - S_2)
#!/usr/bin/python

n = input()
a = input().split()
a.reverse()

for (i, item) in enumerate(a):
  print(str(item), end = ' ' if i != len(a)-1 else '\n')

### FIXED CODE ###

#!/usr/bin/python

n = input()
a = input().split()
a.reverse()

for (i, item) in enumerate(a):
  print(str(item), end = ' ' if i != len(a)-1 else '\n')
def result(m, b):
    sum1 = m
    resmin = m
    for i in range(len(b)):
        resmin += b[i][0]
        if resmin < 0:
            return -1
        else:
            resmin += b[i][1] - b[i][0]
    for i in range(len(b)):
        sum1 += b[i][1]
    if sum1 != 0:
        return -1
    return 0
fin = open('input.txt', 'r')
n = int(fin.readline().strip('\n'))
resmin = 10 ** 7
set_pos = []
set_neg = []
for i in range(n):
    a = fin.readline().strip('\n')
    loc_min = 10 ** 7
    total = 0
    flag = True
    tmp = 0
    for j in range(len(a)):
        if a[j] == '(':
            tmp += 1
        else:
            tmp -= 1
        if tmp < loc_min:
            loc_min = tmp
    total = tmp
    if total >= 0:
        set_pos.append((loc_min, total))
    else:
        set_neg.append((loc_min, total))
total_pos = 0
set_pos = sorted(set_pos, key = lambda l: l[0], reverse = True)
for elem in set_pos:
    if total_pos + elem[0] < 0:
        flag = False
    total_pos += elem[1]   
b = sorted(set_neg, key = lambda l: l[1] - l[0], reverse = True)
#print(b)
print(set_pos, b)
res = result(total_pos, b)
print('No' if (res == -1 or not flag) else 'Yes')

### FIXED CODE ###

def result(m, b):
    sum1 = m
    resmin = m
    for i in range(len(b)):
        resmin += b[i][0]
        if resmin < 0:
            return -1
        else:
            resmin += b[i][1] - b[i][0]
    for i in range(len(b)):
        sum1 += b[i][1]
    if sum1 != 0:
        return -1
    return 0
n = int(input().strip('\n'))
resmin = 10 ** 7
set_pos = []
set_neg = []
for i in range(n):
    a = input().strip('\n')
    loc_min = 10 ** 7
    total = 0
    flag = True
    tmp = 0
    for j in range(len(a)):
        if a[j] == '(':
            tmp += 1
        else:
            tmp -= 1
        if tmp < loc_min:
            loc_min = tmp
    total = tmp
    if total >= 0:
        set_pos.append((loc_min, total))
    else:
        set_neg.append((loc_min, total))
total_pos = 0
set_pos = sorted(set_pos, key = lambda l: l[0], reverse = True)
for elem in set_pos:
    if total_pos + elem[0] < 0:
        flag = False
    total_pos += elem[1]   
b = sorted(set_neg, key = lambda l: l[1] - l[0], reverse = True)
#print(b)
#print(set_pos, b)
res = result(total_pos, b)
print('No' if (res == -1 or not flag) else 'Yes')
N = int(input())
A = [int(input()) for _ in range(N)]

A.sort()
if N % 2 == 0:
    print((sum(A[N//2]) - sum(A[:N//2]))*2 - (A[N//2+1] - A[N//2]))
else:
    print((sum(A[N//2+1]) - sum(A[:N//2]))*2 - min(A[N//2+1] - A[N//2], A[N//2] - A[N//2-1]))

### FIXED CODE ###

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

A.sort()

if N % 2 == 1:
    w = -2*sum(A[:N//2]) +A[N//2] +A[N//2 + 1] + 2*sum(A[N//2 + 2:])
    m = -2*sum(A[:N//2-1]) - A[N//2 - 1] - A[N//2] + 2*sum(A[N//2+1:])
    print(max(w, m))
else:
    print(-2*sum(A[:N//2-1]) - A[N//2-1] + A[N//2] + 2*sum(A[N//2+1:]))
import sys
 import copy
 
 sys.setrecursionlimit(1000000)
 
 
 # input = sys.stdin.readline
 
 # ~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~~~~
 
 def GCD(x, y):
     return x if y == 0 else GCD(y, x % y)
 
 
 def LCM(x, y):
     return x // GCD(x, y) * y
 
 
 A, B, C, D = map(int, input().split())
 
 S = B - A + 1
 
 canC = B // C - (A - 1) // C
 canD = B // D - (A - 1) // D
 canCD = B // LCM(C, D) - (A - 1) // LCM(C, D)
 
 print(S - (canC + canD) + canCD)

### FIXED CODE ###

# import math
# import copy
# import fractions
# import numpy as np
#
# # ===FUNCTION===
#
# def getInputNum():
#     inputNum = int(input())
#     return inputNum
#
# def getInputListInt():
#     outputoData = []
#     inputData = input().split()
#     outputData = [int(n) for n in inputData]
#
#     return outputData
#
# def getSomeInputInt(n):
#     outputDataList = []
#     for i in range(n):
#         inputData = int(input())
#         outputDataList.append(inputData)
#
#     return outputDataList
#
# def getSomeInputListInt(n):
#     inputDataList = []
#     outputDataList = []
#     for i in range(n):
#         inputData = input().split()
#         inputDataList = [int(n) for n in inputData]
#         outputDataList.append(inputDataList)
#
#     return outputDataList
#
# # ===CODE===
#
# num = getInputListInt()
#
# a = num[0]
# b = num[1]
# c = num[2]
# d = num[3]
#
# c_modzero = math.floor(b/c) - math.floor((a-1)/c)
# d_modzero = math.floor(b/d) - math.floor((a-1)/d)
#
# cd = c / fractions.gcd(c, d) *d
#
# cd_modzero = math.floor(b/cd) - math.floor((a-1)/cd)
#
# ans = b - a + 1 - (c_modzero + d_modzero - cd_modzero)
#
# print(int(ans))

import copy



# input = sys.stdin.readline

# ~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~~~~

def GCD(x, y):
    return x if y == 0 else GCD(y, x % y)


def LCM(x, y):
    return x // GCD(x, y) * y


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

S = B - A + 1

canC = B // C - (A - 1) // C
canD = B // D - (A - 1) // D
canCD = B // LCM(C, D) - (A - 1) // LCM(C, D)

print(S - (canC + canD) + canCD)
a, b = map(int, input().split())
 
if (a*b % 2 == 1):
    print('Odd')
else:
    print(Even)

### FIXED CODE ###

a, b = map(int, input().split())
 
if (a*b % 2 == 1):
    print('Odd')
else:
    print('Even')
def comp(a,b):
  r=""
  for x,y in zip(a,b):
    if x==y:
      r += x
    elif y=="?":
      r += x
    elif x=="?":
      r += y
    else:
      return False
  return r

def merge(a,b):
  for i in range(len(a)-len(b)+1):
    m = comp(a[i:],b)
    if m:
      yield a[:i]+m+a[i+len(b):]
  
  for m, lr in merge2(a,b):
    yield m

def merge2(a,b,lr=0):
  for i in range(abs(lr),len(b)):
    if lr>=0:
      m = comp(b[i:], a)
      if m:
        yield  b[:i]+m+a[len(b)-i:], i
    if lr<=0:
      m = comp(b, a[-len(b)+i:])
      if m:
        yield a[:-len(b)+i]+m+b[-i:], -i
  yield a+b, len(b)
  yield b+a, -len(b)

a=input()
b=input()
c=input()
a,b,c=sorted([a,b,c],key=len,reverse=True)

abc = float("inf")
for d in merge(a,b):
  if len(d) > abc:
    break
  l = len(next(merge(d, c)))
  abc = min(abc, l)

for d, lr in merge2(a,c):
  if len(d) > abc:
    break
  if lr > 0:
    lr = b+1-lr
  else:
    lr = -b-1-lr
  l = len(next(merge2(d, b, lr))[0])
  abc = min(abc, l)

print(abc)



### FIXED CODE ###

from itertools import *
from heapq import *

def comp(a,b):
  return all(x==y or "?" in (x,y) for x,y in zip(a, b))

def comp3(a,b,c):
  return 

def comp3(i,j,k,a,b,c):
  m = max(i,j,k)
  n = min(i+len(a),j+len(b),k+len(c))
  return all(len({x,y,z}-{"?"}) <= 1 for x,y,z in zip(a[m-i:n-i],b[m-j:n-j],c[m-k:n-k]))

def _merge_mid(a,b):
  la, lb = map(len,[a,b])
  for i in range(la-lb+1):
    if comp(a[i:],b):
      yield i

def merge_mid(a,b):
  return list(_merge_mid(a,b))

def _merge_right(a,b):
  la, lb = map(len,[a,b])
  for i in range(max(la-lb+1, 1),la):
    if comp(b, a[i-la:]):
      yield i
  yield la

def merge_right(a,b):
  return list(_merge_right(a,b))

class K(int):
  def __new__(cls, *args, **kwargs):
    cb = kwargs.pop("cb")
    i = int.__new__(cls, *args, **kwargs)
    i.cb = cb
    return i

def min_merge(a,b,c):
  keys = sorted([a,b,c],key=len,reverse=True)
  len_keys = list(map(len, keys))
  mid = {(i,j):merge_mid(keys[i],keys[j]) for i,j in permutations(range(3), 2)}
  right = {(i,j):merge_right(keys[i],keys[j]) for i,j in permutations(range(3), 2)}
  
  for i in mid[0,1]:
    for j in mid[0,2]:
      if j+len_keys[2] <= i or i+len_keys[2] <= j or (j-i in mid[1,2] or j-i in right[1,2] or i-j in right[2,1]):
        return len_keys[0]
  
  def candicates(a,b,c):
    return chain(
      (K(i+len_keys[b], cb=lambda:(
       (mid[a,c] and mid[a,c][0]+len_keys[c] <= i) or (mid[b,c] and len_keys[a] <= i+mid[b,c][-1]) or 
       any((i-j in right[c,b] if i>j else j-i in mid[b,c]) and comp3(0,i,j,keys[a],keys[b],keys[c]) for j in dropwhile((i-len_keys[c]).__gt__, mid[a,c]+right[a,c]))
      )) for i in dropwhile((len_keys[c]-len_keys[b]+1).__gt__, right[a,b])),
      (K(min(i+next(dropwhile((len_keys[a]-i+1).__gt__, y))+len_keys[b] for i in x), cb=lambda:True) for (x, y) in [sorted((right[a,c], right[c,b]), key=len)]),
    )
  
  can = merge(*(candicates(x,y,z) for x,y,z in permutations(range(3),3)))
  
  for k in can:
    if k.cb():
      return k
  
  return sum(len_keys)

a=input()
b=input()
c=input()

print(min_merge(a,b,c))
import statistics

a=int(input())
while True:
	if a==0:
		break
	else:
		num=list(map(int,input().split()))
		print(statistics.pstdev(num))



### FIXED CODE ###

import statistics

while True:
	a=int(input())
	num=[]
	if a==0:
		break
	else:
		num=list(map(int,input().split()))
	print(statistics.pstdev(num))
import math
r = int(input())
s = r ** 2 * math.pi
c = 2 * r * math.pi
print('{0:.5f} {1:.5f}'.format(s,c))

### FIXED CODE ###

import math
r = float(input())
s = r ** 2 * math.pi
c = 2 * r * math.pi
print('{0:.5f} {1:.5f}'.format(s,c))
import heapq
import numpy as np

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)

hq = [[-a[0]-b[0]-c[0], 0, 0, 0]]
heapq.heapify(hq)
# visited = [[[0] * z for yy in range(y)] for xx in range(x)]
visited = np.zeros((x, y, z), dtype=int)

for i in range(k):
    ii, ia, ib, ic = heapq.heappop(hq)
    print(-ii)
    na = min(ia+1, x-1)
    nb = min(ib+1, y-1)
    nc = min(ic+1, z-1)
    if visited[na][ib][ic] == 0:
        heapq.heappush(hq, [-a[na] -b[ib] -c[ic], na, ib, ic])
        visited[na][ib][ic] = 1
    if visited[ia][nb][ic] == 0:
        heapq.heappush(hq, [-a[ia] -b[nb] -c[ic], ia, nb, ic])
        visited[ia][nb][ic] = 1
    if visited[ia][ib][nc] == 0:
        heapq.heappush(hq, [-a[ia] -b[ib] -c[nc], ia, ib, nc])
        visited[ia][ib][nc] = 1


### FIXED CODE ###

import heapq

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)

hq = [[-a[0]-b[0]-c[0], 0, 0, 0]]
heapq.heapify(hq)
visited = {(0,0,0)}

for i in range(k):
    ii, ia, ib, ic = heapq.heappop(hq)
    print(-ii)
    na = min(ia+1, x-1)
    nb = min(ib+1, y-1)
    nc = min(ic+1, z-1)
    if not (na, ib, ic) in visited:
        heapq.heappush(hq, [-a[na] -b[ib] -c[ic], na, ib, ic])
        visited.add((na, ib, ic))
    if not (ia, nb, ic) in visited:
        heapq.heappush(hq, [-a[ia] -b[nb] -c[ic], ia, nb, ic])
        visited.add((ia, nb, ic))
    if not (ia, ib, nc) in visited:
        heapq.heappush(hq, [-a[ia] -b[ib] -c[nc], ia, ib, nc])
        visited.add((ia, ib, nc))
W,H,x,y,r = map(int,raw_input().split())
if x-r >= 0 && y-r >= 0 && x+r <= W && y+r <= H :
	print'Yes'
else :
	print'No'

### FIXED CODE ###

W,H,x,y,r = map(int,raw_input().split())
if x-r >= 0 and y-r >= 0 and x+r <= W and y+r <= H :
	print'Yes'
else :
	print'No'
import math
import itertools

N = int(input())
l = [tuple(map(int,input().split())) for _ in range(N)]

if N == 2:
  x1,y1 = l[0]
  x2,y2 = l[1]
  print( 0.5 * math.hypot(x1-x2,y1-y2))
  
else:
  ans = float("INF")
  l_ = itertools.combinations(l,3)
  for points in l_:
    a,b = points[0]
    c,d = points[1]
    e,f = points[2]
    
    if (e-a)*(b-d) == (c-a)*(b-f):
      r = 0.5 * max(math.hypot(c-a,b-d),math.hypot(e-a,b-f),math.hypot(c-e,f-d))
      
    else:
      aa = a * a
      bb = b * b
      cc = c * c
      dd = d * d
      ee = e * e
      ff = f * f

      py = ((e - a) * (aa + bb - cc - dd) - (c - a) * (aa + bb - ee- ff)) / (2 * (e - a)*(b - d) - 2 * (c - a) * (b - f))

      px = (2 * (b - f) * py - aa - bb + ee + ff) / (2 * (e - a)) \
          if (c == a) else (2 * (b - d) * py - aa - bb + cc + dd) / (2 * (c - a))

      r = math.hypot(px - a, py - b)
    flag = 1
    for point in l:
      if flag:
        s,t = point
        if math.hypot(px - s, py - t) > r:
          flag = 0
    if flag:
      ans = min(r,ans)
    
  print(ans)

### FIXED CODE ###

import math
import itertools

N = int(input())
l = [tuple(map(int,input().split())) for _ in range(N)]

if N == 2:
  x1,y1 = l[0]
  x2,y2 = l[1]
  print( 0.5 * math.hypot(x1-x2,y1-y2))
  
else:
  ans = float("INF")
  l_ = itertools.combinations(l,3)
  for points in l_:
    a,b = points[0]
    c,d = points[1]
    e,f = points[2]
    
    if (e-a)*(b-d) == (c-a)*(b-f):
      continue
    else:
      aa = a * a
      bb = b * b
      cc = c * c
      dd = d * d
      ee = e * e
      ff = f * f

      py = ((e - a) * (aa + bb - cc - dd) - (c - a) * (aa + bb - ee- ff)) / (2 * (e - a)*(b - d) - 2 * (c - a) * (b - f))

      px = (2 * (b - f) * py - aa - bb + ee + ff) / (2 * (e - a)) \
          if (c == a) else (2 * (b - d) * py - aa - bb + cc + dd) / (2 * (c - a))

      r = math.hypot(px - a, py - b) + 10**(-7)
    flag = 1
    for point in l:
      if flag:
        s,t = point
        if math.hypot(px - s, py - t) > r:
          flag = 0
    if flag:
      ans = min(r,ans)
      
  l_ = itertools.combinations(l,2)
  for points in l_:
    a,b = points[0]
    c,d = points[1]
    
    
    px,py = (a+c)/2,(b+d)/2

    r = math.hypot(px - a, py - b) + 10**(-7)
    flag = 1
    for point in l:
      if flag:
        s,t = point
        if math.hypot(px - s, py - t) > r:
          flag = 0
    if flag:
      ans = min(r,ans)
    
  print(ans)
#CGL_4-A Convex Polygon - Convex Hull
def isCLKWISE(ph):
    a = [ph[-1][0]-ph[-3][0],ph[-1][1]-ph[-3][1]]
    b = [ph[-2][0]-ph[-3][0],ph[-2][1]-ph[-3][1]]
    crs = a[0]*b[1] - a[1]*b[0]
    if crs < 0 :
        return False
    else :
        return True
    
def ConvexHullScan(P):
    P = sorted(P)
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        while(True):
            if isCLKWISE(phU) :
                break
            else :
                del phU[-2]
                if len(phU) == 2 :
                    break
    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        while(True):
            if isCLKWISE(phL) :
                break
            else :
                del phL[-2]
                if len(phL) == 2 :
                    break
    ph = phU + phL[1:-1]
    return ph

n = int(input())
P = []
for i in range(n):
    P.append([[int(x) for x in input().split()]])
    
Q = ConvexHullScan(P)
Q.reverse()
print(len(Q))
for q in Q:
    idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]
    R = Q[idx:] + Q[:idx]
for r in R:
    print(r[0],r[1])

### FIXED CODE ###

def isCLKWISE(ph) : return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)
      
def ConvexHullScan(P):
    P = sorted(P)
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        while(True):
            try :
                if isCLKWISE(phU) : break
                else : del phU[-2]
            except IndexError : break
    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        while(True):
            try :
                if isCLKWISE(phL) : break
                else : del phL[-2]
            except IndexError : break
    ph = phU + phL[1:-1]
    return ph
  
P = [[int(x) for x in input().split()] for _ in range(int(input()))]
P = ConvexHullScan(P)
P.reverse()
print(len(P))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(P)])[2]
for p in P[idx:] + P[:idx] : print(p[0],p[1])
while True:
  words = raw_input().strip().split(" ")
  count = {};
  for word in words:
    s = count.setdefault(word, 0);
    count[word] = s + 1
  print max(count.items(), key=lambda x: x[1])[0], max(words, key=lambda x: len(x))

### FIXED CODE ###


words = raw_input().strip().split(" ")
count = {};
for word in words:
  s = count.setdefault(word, 0);
  count[word] = s + 1
print max(count.items(), key=lambda x: x[1])[0], max(words, key=lambda x: len(x))
class DoblyLinkedList:
    class node:
        def __init__(self, pre, val, nex):
            self.val = val
            self.pre = pre
            self.nex = nex

    def __init__(self, num):
        self.elements = [None for _ in range(100001)]
        self.elements[0] = self.node(None, num, None)
        self.top = 0
        self.bottom = 0
        self.cnt = 0

    def push_top(self, val):
        self.cnt += 1
        self.elements[self.top].pre = self.cnt
        node = self.node(None, val, self.top)
        self.elements[self.cnt] = node
        self.top = self.cnt

    def push_bottom(self, val):
        self.cnt += 1
        self.elements[self.bottom].nex = self.cnt
        node = self.node(self.bottom, val, None)
        self.elements[self.cnt] = node
        self.bottom = self.cnt

    @staticmethod
    def from_str(s):
        ret = DoblyLinkedList(s[0])
        for v in s[1:]:
            ret.push_bottom(v)
        return ret

    def to_str(self):
        cur = self.top
        val = self.elements[self.top].val
        while self.elements[cur].nex is not None:
            val += self.elements[self.elements[cur].nex].val
            cur = self.elements[cur].nex
        return val


def main():
    s = input()
    d = DoblyLinkedList.from_str(s)
    q = int(input())
    swapped = 0
    for _ in range(q):
        query = input()
        if len(query) == 1:
            swapped = 1 - swapped
            continue
        _, f, c = query.split()
        if swapped:
            if f == '1':
                d.push_bottom(c)
            else:
                d.push_top(c)
        else:
            if f == '1':
                d.push_top(c)
            else:
                d.push_bottom(c)

    if swapped:
        print(d.to_str()[::-1])
    else:
        print(d.to_str())


if __name__ == '__main__':
    main()



### FIXED CODE ###


def main():
    s = input()
    q = int(input())
    bottom = ''
    top = ''
    swapped = 0
    for _ in range(q):
        query = input()
        if len(query) == 1:
            swapped = 1 - swapped
            continue
        _, f, c = query.split()
        if swapped:
            if f == '1':
                bottom += c
            else:
                top += c
        else:
            if f == '1':
                top += c
            else:
                bottom += c

    if swapped:
        print(bottom[::-1] + s[::-1] + top)
    else:
        print(top[::-1]+s+bottom)


if __name__ == '__main__':
    main()
a, b = map(int, input().split())
from numpy import gcd, sqrt
m = gcd(a,b)
cnt = 1
for i in range(2, int(sqrt(m))+1):
    div = False
    while m%i == 0:
        div = True
        m = m//i
    if div:
        cnt += 1
    if m == 1:
        break
if m > 1:
    cnt += 1
print(cnt)

### FIXED CODE ###

a, b = map(int, input().split())
from fractions import gcd
from numpy import sqrt
m = gcd(a,b)
cnt = 1
for i in range(2, int(sqrt(m))+1):
    div = False
    while m%i == 0:
        div = True
        m = m//i
    if div:
        cnt += 1
    if m == 1:
        break
if m > 1:
    cnt += 1
print(cnt)
X = int(input())
X = X + 1
while True:
    for i in range(0, X):
        if X % i == 0:
            prime = X
            break
        else:
            X += 1
print(X)

### FIXED CODE ###

X = int(input())
prime = None
while True:
    for i in range(2, X):
        if X % i == 0:
            break
    else:
        prime = X
    if prime != None:
        break
    else:
        X += 1

print(prime)