Harryxun/stf_run huggingface dataset:
N, K = map(int, input().split())
X = list(map(int, input().split()))

x_minus = [a for a in X if a < 0]
x_plus = [a for a in X if a >= 0]

ans = float("inf")
for i in range(K+1):
    if i == 0:
        if len(x_plus) >= K:
            dis = x_plus[K - 1]
            ans = min(ans, dis)
        else:
            continue
    if i != 0:
        if len(x_minus) > i and len(x_plus) >= K - i:
            dis = 2 * abs(x_minus[-i]) + x_plus[K - i - 1]
            ans = min(ans, dis)
            dis = 2 * x_plus[K - i - 1] + abs(x_minus[-i])
            ans = min(ans, dis)
        else:
            continue
    if i == K:
        if len(x_minus) >= K:
            dis = abs(x_minus[-K])
            ans = min(ans, dis)


print(ans)


### FIXED CODE ###

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

x_minus = [a for a in X if a < 0]
x_plus = [a for a in X if a >= 0]

ans = float("inf")
for i in range(K+1):
    if i == 0:
        if len(x_plus) >= K:
            dis = x_plus[K - 1]
            ans = min(ans, dis)
        else:
            continue
    elif 1 <= i <= K - 1:
        if len(x_minus) >= i and len(x_plus) >= K - i:
            dis = 2 * abs(x_minus[-i]) + x_plus[K - i - 1]
            ans = min(ans, dis)
            dis = 2 * x_plus[K - i - 1] + abs(x_minus[-i])
            ans = min(ans, dis)
        else:
            continue
    elif i == K:
        if len(x_minus) >= K:
            dis = abs(x_minus[-K])
            ans = min(ans, dis)


print(ans)
a,b = map(int,input().split())
orint("Possible" if a%3==0 or b%3==0 or (a+b)%3==0 else "Impossible")

### FIXED CODE ###

a,b = map(int,input().split())
print("Possible" if a%3==0 or b%3==0 or (a+b)%3==0 else "Impossible")
N = int(input())

A = []

for i in xrange(N):
	b= input()
	if (" " in b):
		b, c = b.split()
		c = int(c)
	
	if b == "insert":
		A.insert(0, c)
	elif b == "delete":
		if (c in A):
			A.remove(c)
	elif b == "deleteFirst":
		A.pop(0)
	elif b == "deleteLast":
		A.pop()

print(" ".join(map(str, A)))
	

### FIXED CODE ###

from collections import deque

N = int(input())

A = deque()

for i in range(N):
	b= input()
	if b == "deleteFirst":
		A.popleft()
	elif b == "deleteLast":
		A.pop()
	else:
		b, c = b.split()
		c = int(c)
	
		if b == "insert":
			A.appendleft(c)
		elif b == "delete":
			if (c in A):
				A.remove(c)

print(" ".join(map(str, A)))
a = input()
ans = upper(a)
if a = ans:
  print("A")
else:
  print("a")

### FIXED CODE ###

a = input()
ans = a.upper()
if a == ans:
  print("A")
else:
  print("a")
n,k=map(int,input().split())
if n<k:
    print(n)
elif n==k:
    print('0')
else:
    a=n-k*(n//k)
    print(min(a,abs(a-k)))

### FIXED CODE ###

x,y,z=map(int,input().split())

p=x
x=y
y=p

p=x
x=z
z=p

print('%s %s %s' %(x,y,z))
x,y = map(int,input().split())

if abs(y) > abs(x):
  if x > 0 and y > 0:
    print(y-x)
  elif x < 0 and y <0:
    print(y-x+2)
  else:
    print(y-x+1)
elif abs(y) < abs(x):
  if x > 0 and y > 0:
    print(ads(y-x+2))
  elif x < 0 and y <0:
    print(abs(y-x))
  else:
    print(abs(y-x+1))
else:
  if x == y:
    print("0")
  else:
    print("1")
    

### FIXED CODE ###

x,y = map(int,input().split())
 
if abs(y) > abs(x):
  if x >= 0 and y >= 0:
    print(y-x)
  elif x < 0 and y <0:
    print(abs(y)-abs(x)+2)
  else:
    print(abs(y)-abs(x)+1)
elif abs(y) < abs(x):
  if x > 0 and y > 0:
    print(x - y + 2)
  elif x <= 0 and y <=0:
    print(abs(abs(y)-abs(x)))
  else:
    print(abs(abs(y)-abs(x))+1)
else:
  if x == y:
    print("0")
  else:
    print("1")
def main():
    _ = input()
    monsters = [int(n) for n in input().split(" ")]
    max_gcd = reduce(math.gcd, monsters)
    print(max_gcd)

if __name__ == "__main__":
    main()

### FIXED CODE ###

from functools import reduce

def gcd(a, b):
    x = max(a, b)
    y = min(a, b)
    if x % y == 0:
        return y
    else:
        while x % y != 0:
            z = x % y
            x = y 
            y = z
        else:
            return z

def main():
    _ = input()
    monsters = [int(n) for n in input().split(" ")]
    max_gcd = reduce(gcd, monsters)
    print(max_gcd)

if __name__ == "__main__":
    main()
N, X, Y = map(int, input().split())
X -= 1
Y -= 1　　#１のところを０にするなど一つずつずらす
 
def dist(a, b):
    return min(abs(b-a), abs(X-a) + 1 + abs(b-Y), abs(Y-a) + 1 + abs(b-X))
 #＋１は間の一つ繋がっている分

ANS = [0] * N  　　　#0がN個のリストを作成。一つ目はk=0の時（同じところ）
for i in range(N):
    for j in range(i):
        ANS[dist(i, j)] += 1　　#0にずらしたことで０から始まるi,jに対応できている
        
        #i,jの最小値のindexに１ずつ足していく
 
for a in ANS[1:]:　#indexが１以降（数字の差が１以上）のものを一つづつ出力
    print(a)

### FIXED CODE ###

N, X, Y = map(int, input().split())
X -= 1
Y -= 1
 
def dist(a, b):
  return min(abs(b-a), abs(X-a) + 1 + abs(b-Y), abs(Y-a) + 1 + abs(b-X))

ANS = [0] * N
for i in range(N):
  for j in range(i):
    ANS[dist(i, j)] += 1

        
for a in ANS[1:]:
  print(a)
S = [*input()] # これで文字列を一文字にできる
T = input()

for i in range(0, len(S)):
    word = ''
    for j in range(0, len(S)):
        index = (i + j) % len(S)
        word += S[index]
    if(word == T):
        print('Yes')
        break
    elif(i == j):
        print('No')
        break


### FIXED CODE ###

S = tuple(input()) # これで文字列を一文字にできる
T = input()

for i in range(0, len(S)):
    word = ''
    for j in range(0, len(S)):
        index = (i + j) % len(S)
        word += S[index]
    if word == T:
        print('Yes')
        break
    elif i == j:
        print('No')
        break
# -*- coding:utf-8 -*-
N=int(input())
button=[]
for i in range(N):
  button.append(int(input()))

number=0
count=0
footprint=[0]
while number!=1:
  number=button[number]-1
  count+=1
    if number in footprint:
      print(-1)
      exit()
  footprint.append(number)
print(count)

### FIXED CODE ###

# -*- coding:utf-8 -*-
import sys

a=[int(i)-1 for i in sys.stdin]
N=a[0]+1
a=a[1:]

done=[False]*N

ans=0
i=0

while True:
  if done[i]==False:
    done[i]=True
    ans+=1
    if a[i]==1:
      break
    i=a[i]

  
  else:
    ans=-1
    break
    
print(ans)
def check(s, t):
	for i in range(len(s)):
		if s[i] == t[i] or s[i] == '?':
			continue
		return False
	return True

def norm(s):
	ans = []
	for i in s:
		ans.append('a' if i == '?' else i)
	ans[0] = 'a'
	return "".join(ans)

def resolve():
	s = list(input())
	t = list(input())
	if len(s) < len(t):
		print('UNRESTORABLE')
		return
	for i in range(len(s) - len(t) + 1):
		if check(s[i:i+len(s)], t):
			for j in range(len(t)):
				s[i+j] = t[j]
			print(norm(s))
			return
	print('UNRESTORABLE')
resolve()

### FIXED CODE ###

import copy

def check(s, t, k):
	for i in range(len(t)):
		if s[i+k] != t[i] and s[i+k] != '?':
			return False
	return True

def construct(s, t, k):
	ans = copy.deepcopy(s)
	for i in range(len(t)):
		ans[i+k] = t[i]
	for i in range(len(s)):
		if ans[i] == '?':
			ans[i] = 'a'
	return "".join(ans)

def resolve():
	s = list(input())
	t = list(input())
	ans = []
	if len(s) < len(t):
		print('UNRESTORABLE')
		return
	for i in range(len(s) - len(t) + 1):
		if check(s, t, i):
			ans.append(construct(s, t, i))
	if len(ans) >= 1:
		print(min(ans))
	else:
		print('UNRESTORABLE')
resolve()
n = input()

tmp = int(n[0])+int(n[1])+int(n[2])

if int(n)%tmp == 0:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

n = input()
tmp = 0
 
for i in range(len(n)):
  tmp += int(n[i])
 
if int(n)%tmp == 0:
  print("Yes")
else:
  print("No")
# coding: utf-8
from functools import lru_cache
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

@lru_cache(maxsize = None)
def f(v):
    if not arc[v]:
        return(0)
    return(max(f(nv) for nv in arc[v]) + 1)

n, m = map(int, input().split()) # 2 <= n <= 10^5, 1 <= m <= 10^5
arc = [[] for _ in range(n)]
for _ in range(m):
    x, y = map(int, input().split())
    arc[x - 1].append(y - 1)
print(max(f(v) for v in range(n)))


### FIXED CODE ###

# coding: utf-8
from functools import lru_cache

import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)

@lru_cache(maxsize = None)
def f(v):
    if not arc[v]:
        return(0)
    return(max(f(nv) for nv in arc[v]) + 1)

n, m = map(int, input().split()) # 2 <= n <= 10^5, 1 <= m <= 10^5
arc = [[] for _ in range(n)]
for _ in range(m):
    x, y = map(int, input().split())
    arc[x - 1].append(y - 1)
print(max(f(v) for v in range(n)))
n = int(input())
ans=""
while n!=0:
  if n%2==0:
    ans = "0"+ans
  else
    n-=1
    ans = "1"+ans
  n//=-2  

if n==0:
  print("0")
else
  print(ans)

### FIXED CODE ###

n = int(input())
ans=""
while n!=0:
  if n%2==0:
    ans = "0"+ans
  else:
    n-=1
    ans = "1"+ans
  n//=-2  

if ans=="":
  print("0")
else:
  print(ans)
# coding: utf-8

import sys
input = sys.stdin.readline

import math

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

def gcd(num):
    if len(num) == 1:
        return num[0]
    else:
        return math.gcd(gcd(num[0:1]), gcd(num[1:]))

print(gcd(A))



### FIXED CODE ###

# coding: utf-8

import sys
input = sys.stdin.readline

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

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

first_gcd = A[0]
for i in range(len(A)):
    first_gcd = gcd(first_gcd, A[i])

print(first_gcd)
N = int(input())
list = [int(input())for _ in range(N)]
print(round(sum(list) - max(list)/2))

### FIXED CODE ###

D = int(input())
if D == 25:
  print("Christmas")
elif D == 24:
  print("Christmas Eve")
elif D == 23:
  print("Christmas Eve Eve")
elif D == 22:
  print("Christmas Eve Eve Eve")
while True:
    try:
        path = [0]*100
        while True:
            a,b = map(int, raw_input().split())
            if a == 0: break
            path[a-1] += 1; path[b-1] += 1
        if (path[0]%2 == path[1]%2 == 1 ):
            print "OK"
        else:
            print "NG"
    except:
        break

### FIXED CODE ###

#coding:utf-8
while 1:
    try:
        #初期化
        key=[0]*101
        #オイラー路：すべての頂点のうち、次数が奇数であるものがちょうど２つ(入口と出口)
        while 1:
            input = map(int, raw_input().split())
            if(input[0] == 0 and input[1] == 0):
                break
            key[input[0]]+=1
            key[input[1]]+=1

        if(key[1]%2 == 1 and key[2]%2==1 and len(filter(lambda x:x%2==1,key[3:]))==0):
            print "OK"
        else:
            print "NG"
    except:
        break
a,b=map(int,input().split())
cntA,cntB=0,0
print(100,100)
flag=False
arr=[['#']*100 for i in range(100)]
l=[]
cntB=1
for i in range(2,100,4):
  if flag:break
  for j in range(2,100,4):
    l.append((i,j))
    for y in range(i-1,i+2):
      for x in range(j-1,j+2):
        arr[y][x]='.'
    cntA+=1
    if cntA==a:
      flag=True
      break
while cntB<b:
  cntB+=1
  s,t=l.pop()
  arr[s][t]='#'
for i in range(100):
  print(''.join(arr[i]))

### FIXED CODE ###

a,b=map(int,input().split())
cntA,cntB=0,0
print(100,100)
flag=False
if a>=b:
  arr=[['#']*100 for i in range(100)]
  l=[]
  cntB=1
  for i in range(2,99,4):
    if flag:break
    for j in range(2,99,4):
      l.append((i,j))
      for y in range(i-1,i+2):
        for x in range(j-1,j+2):
          arr[y][x]='.'
      cntA+=1
      if cntA==a:
        flag=True
        break
  while cntB<b:
    cntB+=1
    s,t=l.pop()
    arr[s][t]='#'
  for i in range(100):
    print(''.join(arr[i]))
else:
  arr=[['.']*100 for i in range(100)]
  l=[]
  cntA=1
  for i in range(2,99,4):
    if flag:break
    for j in range(2,99,4):
      l.append((i,j))
      for y in range(i-1,i+2):
        for x in range(j-1,j+2):
          arr[y][x]='#'
      cntB+=1
      if cntB==b:
        flag=True
        break
  while cntA<a:
    cntA+=1
    s,t=l.pop()
    arr[s][t]='.'
  for i in range(100):
    print(''.join(arr[i]))
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")



h,w = list(map(int, input().split()))
n = int(input())
from collections import defaultdict
mind = [10**18] * h
dw = defaultdict(list)
for i in range(n):
    r,c,a = map(int, input().split())
    r -= 1
    c -= 1
    mind[r] = min(mind[r], a)
    dw[c].append((a,r))
# 0未満になる要素があるか判定
es = [[] for _ in range(h)]
def main():
    ans = True
    for c in range(w):
        if len(dw[c])<=1:
            continue
        dw[c].sort()
        tmp = 0
        for i in range(len(dw[c])-1):
            u = dw[c][i][1]
            v = dw[c][i+1][1]
            val = dw[c][i+1][0] - dw[c][i][0]
            es[u].append((val, v))
            es[v].append((-val, u))
            tmp += val
            if mind[v]<tmp:
                return False
#     print(es)
#     print(dw)
    vals = [None]*h
    assert False
    for start in range(h):
        if vals[start] is not None:
            continue
        q = [start]
        vals[start] = 0
        while q:
            u = q.pop()
            for d,v in es[u]:
                if vals[v] is None:
                    vals[v] = vals[u] + d
                elif vals[v]!=vals[u]+d:
                    return False
    return True
ans = main()
if ans:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


h,w = list(map(int, input().split()))
n = int(input())
from collections import defaultdict
mind = [10**15] * h
dw = defaultdict(list)
for i in range(n):
    r,c,a = map(int, input().split())
    r -= 1
    c -= 1
    mind[r] = min(mind[r], a)
    dw[c].append((a,r))
# 0未満になる要素があるか判定
es = [[] for _ in range(h)]
def main():
    ans = True
    for c in range(w):
        if len(dw[c])<=1:
            continue
        dw[c].sort()
        tmp = 0
        for i in range(len(dw[c])-1):
            u = dw[c][i][1]
            v = dw[c][i+1][1]
            val = dw[c][i+1][0] - dw[c][i][0]
            es[u].append((val, v))
            es[v].append((-val, u))
            tmp += val
            if mind[v]<tmp:
                return False
#     print(es)
#     print(dw)
    vals = [None]*h
    for start in range(h):
        if vals[start] is not None:
            continue
        q = [start]
        vals[start] = 0
        l = [(0, mind[start])]
        while q:
            u = q.pop()
            for d,v in es[u]:
                if vals[v] is None:
                    vals[v] = vals[u] + d
                    l.append((vals[v], mind[v]))
                    q.append(v)
                elif vals[v]!=vals[u]+d:
                    return False
        l.sort()
        for i in range(len(l)):
            if l[i][1]<l[i][0]-l[0][0]:
                return False
#     for u in range(h):
#         for d,v in es[u]:
#             if vals[u]+d!=vals[v]:
#                 return False
    return True
ans = main()
if ans:
    print("Yes")
else:
    print("No")
import numpy as np

def prime_decomposition(n):
  i = 2
  t = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      t.append(i)
    i += 1
  if n > 1:
    t.append(n)
  return t

def get_binary(arr):
	lim = 10**9
	a = np.prod(arr[:-1])
	c = 0
	b = arr[-1]
	while a > lim or b > lim:
		c+=1
		a=np.prod(arr[c:-1])
		b = arr[-1]
		for i in range(c):
			b = b*arr[i]
	return a,b

lim = 10**9
S = int(input())
t = prime_decomposition(S)
a = 1
ta = [0]

while max(t) >= lim or max(ta) >= lim or len(t) == 1:
	a*= S//(10**(len(str(S)) - 8))
	t = prime_decomposition(S-a)
	ta = prime_decomposition(a)

x1,x2,x3,y1,y2,y3 = 0,0,0,0,0,0

x1,y1 = 0,0
x2,y3 = get_binary(t)
x3,y2 = get_binary(ta)

print("%d %d %d %d %d %d" % (x1,y1,x2,y2,x3,y3))

### FIXED CODE ###

S = int(input())
lim = 10**9
x1,y1 = 0,0
x2,y2 = 10**9, 1
x3 = (lim-S%lim)%lim
y3 = (S+x3)//lim
print("%d %d %d %d %d %d" % (x1,y1,x2,y2,x3,y3))
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def resolve():
    it = map(int, sys.stdin.read().split())
    N, Q = next(it), next(it)

    if Q == 3:
        raise 1
    A = [None] * (N+Q)
    for i in range(N):
        ci = next(it)-1
        A[i] = (i, 0, ci)
    for i in range(Q):
        l, r = next(it) - 1, next(it) - 1
        A[N+i] = (r, 1, l, i)

    A.sort()
    dp = [-1] * N
    dp2 = [0] * N

    ans = [0] * Q
    for r, cmd, *arg in A:
        if cmd == 0:
            ci, = arg
            for j in range(dp[ci], r):
                dp2[j+1] += 1
            dp[ci] = r
            continue

        l, i = arg
        ans[i] = dp2[l]

    print(*ans, sep="\n")


if __name__ == "__main__":
    resolve()


### FIXED CODE ###

#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def resolve():
    it = map(int, sys.stdin.read().split())
    X = 19
    N, Q = next(it), next(it)
    X = Q.bit_length()
    b1, br, bc = (1 << X)-1, 2*X+1, 1<<X

    Aa = [next(it)-1 for i in range(N)]
    Aq = [0] * Q
    Ac = [0] * Q
    for i in range(Q):
        l, r = next(it)-1, next(it)-1
        Aq[i] = r<<X | i
        Ac[i] = l

    Aq.sort()
    dp = [0] * N

    N1 = (2*N+1)//2
    dp2 = [0] * (N1*2)

    ans = [0] * Q
    offset = 0
    for arg in Aq:
        r = arg >> X
        i = arg & b1

        for j in range(offset, r+1):
            ci = Aa[j]

            lo = N1 + dp[ci]
            hi = N1 + j

            while lo < hi:
                if lo & 1:
                    dp2[lo] += 1
                    lo += 1
                if not hi & 1:
                    dp2[hi] += 1
                    hi -= 1
                lo >>= 1; hi >>= 1;

            if lo == hi: dp2[lo] += 1

            dp[ci] = j + 1
        offset = r+1
        l = Ac[i]

        num = 0
        j = l + N1
        while j > 0:
            num += dp2[j]
            j >>= 1
        ans[i] = num

    print(*ans, sep="\n")


if __name__ == "__main__":
    resolve()
n = int(input())

a = input()
b = input()

res = ""
for i in range(n):
  res += a[i]
  res += b[i]
print(res)

### FIXED CODE ###

n = int(input())

a = input().split()

res = ""
for i in range(n):
  res += a[0][i]
  res += a[1][i]
print(res)
import sys
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

# 入力を整数に変換して受け取る
def input_int():
    return int(input())

def map_int_input():
    return map(int, input())

MII = map_int_input

def MII_split():
    return map(int, input().split())

def MII_to_index():
    return map(to_index, input())

def MII_split_to_index():
    return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs():
    return list(map(int, input()))

LII = list_int_inputs

def LII_split():
    return list(map(int, input().split()))

# 2次元リスト化
def LII_2D(rows_number):
    return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number):
    return [LII_split() for _ in range(rows_number)]


import logging
import sys
import unittest
from io import StringIO

logging.basicConfig(level=logging.DEBUG)


def resolve():
import sys
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

# 入力を整数に変換して受け取る
def input_int(): return int(input())

def map_int_input(): return map(int, input())

MII = map_int_input

def MII_split(): return map(int, input().split())

def MII_to_index(): return map(to_index, input())

def MII_split_to_index(): return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs(): return list(map(int, input()))

LII = list_int_inputs

def LII_split(): return list(map(int, input().split()))

# 2次元リスト化
def LII_2D(rows_number): return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number): return [LII_split() for _ in range(rows_number)]

N=input_int()
N%=10
if N==3:
    ans = 'bon'
elif N in [0, 1, 6, 8]:
    ans = 'pon'
else:
    ans = 'hon'
print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

# 入力を整数に変換して受け取る
def input_int():
    return int(input())

def map_int_input():
    return map(int, input())

MII = map_int_input

def MII_split():
    return map(int, input().split())

def MII_to_index():
    return map(to_index, input())

def MII_split_to_index():
    return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs():
    return list(map(int, input()))

LII = list_int_inputs

def LII_split():
    return list(map(int, input().split()))

# 2次元リスト化
def LII_2D(rows_number):
    return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number):
    return [LII_split() for _ in range(rows_number)]

N = input_int()
N %= 10
if N == 3:
    ans = 'bon'
elif N in [0, 1, 6, 8]:
    ans = 'pon'
else:
    ans = 'hon'
print(ans)
import math
N = int(input())
ans = 2
tp, ap = 0, 0
for i in range(N):#ans以上での比からの最小値でans更新,
    #A+Tのn倍、ただしn>=ans/(t+a)
    t, a = map(int, input().split())
    k = max(math.ceil(tp/t), math.ceil(ap/a))
    t, a = t*k, a*k
    c = math.ceil(ans/(t+a))
    while True:#ansが前回のans以上になるようにする
        if (t+a)*c >= ans:
            ans = (t+a)*c
            break
        c += 1
    tp, ap = t*c, a*c
print(ans)

### FIXED CODE ###

n = int(input())
t = []
a = []
for i in range(n):
    c = list(map(int,input().split()))
    t.append(c[0])
    a.append(c[1])
for i in range(n-1):
    d = max(1,-(-t[i]//t[i+1]),-(-a[i]//a[i+1]))
    t[i+1] =t[i+1]*d
    a[i+1] =a[i+1]*d
print(t[-1]+a[-1])
n=int(input())
print(len([i for i in range (1,int(input())+1) if i%2 == 1 and len([1 for x in range(1,i+1) if i%x==0]) == 8]))

### FIXED CODE ###

n=int(input())
print(len([i for i in range (1,n+1) if i%2 == 1 and len([1 for x in range(1,i+1) if i%x==0]) == 8]))
n = str(input())
sn = 0
for i in range(len(n)):
    sn += int(n[i])
if n % sn == 0:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

n = str(input())
sn = 0
for i in range(len(n)):
    sn += int(n[i])
if int(n) % sn == 0:
    print("Yes")
else:
    print("No")
n_str = input()
for i in range(3):
  if n_str[i] == '1':
    n_str[i] = '9'
  else:
    n_str[i] = '1'
    
print(int(n_str))

### FIXED CODE ###

n_str = input()
res = 0
for i in range(3):
  s = (10 - int(n_str[i])) * 10**(2-i)
  res = res + s


print(res)
n = int(raw_input())
A = map(int, raw_input().split())

q = int(raw_input())
M = map(int, raw_input().split())

result = []
for i in range(q):
    result.append('no')

for i in range(n-1):
    sum_n = A[i]
    for j in range(n-1-i):
        ad = A[i+1+j]
        for k in range(n-2-j):
            sum_n = sum_n + ad
            ad = ad + A[i+j+2+k]
            if M[k] == sum_n:
                result[k] = 'yes'

for i in result:
    print(i)

### FIXED CODE ###


n = int(raw_input())
A = map(int, raw_input().split())

q = int(raw_input())
M = map(int, raw_input().split())

result = []
for i in range(q):
    result.append('no')

def adder(axis = 0, nums = [0], M = [0], q = 0):
    for i in range(q):
        if M[i] == axis:
            result[i] = 'yes'
    length = len(nums)
    if length != 0:
        for i in range(length):
            sum_n = axis + nums[i]
            adder(sum_n, nums[i+1:], M, q)

for i in range(n):
    adder(A[i], A[i+1:], M, q)

for i in result:
    print(i)
a=list(raw_input().split(" ")))
b=map(int,a)
b.sort()
print " ".join(map(str,b))

### FIXED CODE ###

a=list(raw_input().split(" "))
b=map(int,a)
b.sort()
print " ".join(map(str,b))
n=int( input() )
a=[int(i)+1 for i in input().split()]

c=[0,0,0]
ans=1
mod=1000000007
for aa in a:
    ans = ans*c.count(aa-1) %mod
    c[c.index(aa-1)]+=1
print(ans)

### FIXED CODE ###

n=int( input() )
a=[int(i)+1 for i in input().split()]

c=[0,0,0]
ans=1
mod=1000000007
out=0
for aa in a:
    if aa-1 in c:
        ans = ans*c.count(aa-1) %mod
        c[c.index(aa-1)]+=1
    else:
        out=1
        break
if out==1:
    print(0)
else:
    print(ans)