Harryxun/stf_run huggingface dataset:
n=int(input())
s=list(input())

num=2**((n-1).bit_length())
st=[[0]*(2*num) for _ in range(26)]

def update(pos,a,x):
  pos+=num
  st[a][pos]=x
  while pos>=0:
    pos=(pos-1)//2
    st[a][pos]=st[a][2*pos+1]|st[a][2*pos+2]
    
def query(l,r):
  ret=0
  for a in range(26):
    tl=l+num
    tr=r+num
    tmp=0
    while tl<tr:
      if tr&1==1:
        tr-=1
        tmp=max(tmp,st[a][tr-1])
      if tl&1==1:
        tmp=max(tmp,st[a][tl-1])
        tl+=1
      tl>>=1
      tr>>=1
    if tmp!=0:
      tmp=1
    ret+=tmp
  return ret

for i in range(n):
  update(i,ord(s[i])-97,1)

q=int(input())
for _ in range(q):
  a,b,c=map(str,input().split())
  a=int(a)
  b=int(b)-1
  if a==1:
    if c==s[b]:
      continue
    update(b,ord(s[b])-97,0)
    update(b,ord(c)-97,1)
    s[b]=c
  elif a==2:
    c=int(c)-1
    print(query(b,c+2))

### FIXED CODE ###

def ctoi(c):
  return ord(c)-97

n=int(input())
s=list(input())

bits=[[0]*(n+1) for _ in range(26)]

def query(pos):
  ret=[0]*26
  for i in range(26):
    tmp=0
    p=pos
    while p>0:
      tmp+=bits[i][p]
      p-=p&(-p)
    ret[i]=tmp
  return ret

def update(pos,a,x):
  while pos<=n:
    bits[a][pos]+=x
    pos+=pos&(-pos)

for i in range(n):
  update(i+1,ctoi(s[i]),1)

q=int(input())
for _ in range(q):
  flag,a,b=map(str,input().split())
  flag=int(flag)
  a=int(a)
  if flag==1:
    if s[a-1]==b:
      continue
    else:
      update(a,ctoi(s[a-1]),-1)
      update(a,ctoi(b),1)
      s[a-1]=b
  elif flag==2:
    b=int(b)
    cnt1=query(b)
    cnt2=query(a-1)
    ans=0
    for i in range(26):
      if cnt1[i]-cnt2[i]>0:
        ans+=1
    print(ans)
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys

sys.setrecursionlimit(1000000)

def fact(num):
    if num <= 1:
        return 1
    return fact(num - 1) + 1

print fact(200000)


### FIXED CODE ###

while True:
    S = raw_input()[::-1]
    if S == '0' : break
    m = [1] + [0] * 10
    diff = ans = 0
    even = 1
    for c in S:
        num = int(c)
        diff = (diff + num * even) % 11
        if num : ans += m[diff]
        m[diff] += 1
        even *= -1
    print ans
import bisect
N = int(input())
*A, = map(int, input().split())
A.sort()
a = []
b = []
last = 0
for i in range(N):
    if last != A[i]:
        a.append([A[i], 0])
        b.append(A[i])
        last = A[i]
    a[-1][1] += 1


def factorList(n):
    # [素因数]=数を出力
    f = {}
    c = 0
    r = int(n**0.5)
    l = []
    for i in range(2, r+2):
        while n % i == 0:
            c += 1
            n = n//i
        if c != 0:
            l.append([i, c])
            c = 0
    if n != 1:
        l.append([n, 1])
    return l


def cmb(a, i, h, t):
    if i >= len(a):
        return h[t]
    for j in range(a[i][1]+1):
        d = cmb(a, i+1, h, t*pow(a[i][0], j))
        if d:
            return True
    return False


h = [False]*(10**6+1)
ans = 0
for n, c in a:
    if c == 1:
        f = {}
        cc = 0
        r = int(n**0.5)
        l = []
        nn = n
        for i in range(2, r+2):
            while nn % i == 0:
                cc += 1
                nn = nn//i
            if cc != 0:
                l.append([i, cc])
                cc = 0
        if n != 1:
            l.append([n, 1])

        if not cmb(l, 0, h, 1):
            ans += 1
    h[n] = True

print(ans)


### FIXED CODE ###

from collections import Counter
N = int(input())
*A, = map(int, input().split())
A.sort()
c = Counter(A)
ans = 0
d = [0]*(10**6+1)
for i in range(N):
    if d[A[i]] == 0:
        if c[A[i]] == 1:
            ans += 1
        j = A[i]
        while j <= (10**6):
            d[j] += 1
            j += A[i]
print(ans)
a,b,v,w,t = map(int,input().split())

d = abs(b-a)
p = abs(wt-vt)
i=0
for i in range(t):
  if p>=d:
    print("YES")
  else:
    print("NO")


### FIXED CODE ###

a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if v <= w:
    print('NO')
else:
    if 1 <= (abs(b - a) / (v - w)) <= t:
        print('YES')
    else:
        print('NO')
import collections
n=int(input())
v=list(map(int, input().split()))
v1=v[0:n:2]
v2=v[1:n:2]
v10=collections.Counter(v1)
v11=v10.most_common()
v20=collections.Counter(v2)
v21=v20.most_common()
if v11[0][0]==v21[0][0] and v11[0][1]==n//2 and v21[0][1]==n//2:
    print(n//2)
elif v11[0][0]==v21[0][0]:
    x1=n//2-v11[0][1]
    x2=n//2-v11[1][1]
    y1=n//2-v21[0][1]
    y2=n//2-v21[1][1]
    print(min(x1+y2,x2+y1))
    
else:
    x=n//2-v11[0][1]
    y=n//2-v21[0][1]
    print(x1+y1)

### FIXED CODE ###

import collections
n=int(input())
v=list(map(int, input().split()))
v1=v[0:n:2]
v2=v[1:n:2]
v10=collections.Counter(v1)
v11=v10.most_common()
v20=collections.Counter(v2)
v21=v20.most_common()
if v11[0][0]==v21[0][0] and v11[0][1]==n//2 and v21[0][1]==n//2:
    print(n//2)
elif v11[0][0]==v21[0][0]:
    x1=n//2-v11[0][1]
    x2=n//2-v11[1][1]
    y1=n//2-v21[0][1]
    y2=n//2-v21[1][1]
    print(min(x1+y2,x2+y1))
    
else:
    x1=n//2-v11[0][1]
    y1=n//2-v21[0][1]
    print(x1+y1)
a='abcdefghijklmnopqrstuvwxyz'
out=''
n=int(input())
while n>26:
  out=a[n%26+1]+out
  n//=26
print(out)

### FIXED CODE ###

a = 'abcdefghijklmnopqrstuvwxyz'
n = int(input())
r = 26
d = 1
while n-r > 0:
    n -= r
    r *= 26
    d += 1
n -= 1
name = ''
for i in range(d):
    if n >= 26:
        name = a[n % 26]+name
        n //= 26
    elif n > 0:
        name = a[n]+name
        n = 0
    else:
        name = a[n]+name
print(name)
a = list(map(int,input().split())
a.sort()
print(a[0]+a[1])

### FIXED CODE ###

a = list(map(int,input().split()))
a.sort()
print(a[0]+a[1])
def f(a, b, x):
  return int(a*x/b) - (a*int(x/b))
A, B, N = map(int, input().split())
print(f(A, B, min(B-1, N))

### FIXED CODE ###

def f(a, b, x):
  return int(a*x/b) - (a*int(x/b))
A, B, N = map(int, input().split())
print(f(A, B, min(B-1, N)))
N = int(input())
Alist = list(map(int, input().split()))
def gcd(a,b):
    while b!=0:
        a,b = b, a%b
    return a
def gcds(numbers):
    if len(numbers) == 2:
        return gcd(*numbers)
    else:
        n1 = gcd(numbers[0], numbers[1])
        return gcds(*[n1]+numbers[2:])
if len(Alist)>2:
    gcdlist = [gcds(Alist[:i]+Alist[i+1:]) for i in range(N)]
    print(max(gcdlist))
else:
    print(gcds(Alist))

### FIXED CODE ###

from fractions import gcd
N = int(input())
Alist = [0]+list(map(int, input().split()))+[0]
Rlist = [0]*(N+2)
Llist = [0]*(N+1)
for i in range(N):
    Llist[i+1] = gcd(Llist[i], Alist[i])
    Rlist[N-i] = gcd(Rlist[N-i+1], Alist[N-i+1])
print(max([gcd(Rlist[i], Llist[i]) for i in range(1,N+1)]))
import sys
input = sys.stdin.readline
import numpy as np

def print_sub(A, m, c):
    A = np.array(A)
    A -= 1
    print(m -len(np.nonzero(A)[0]))
    c +=1
    if c < m:
        return print_sub(A, m, c)
    else:
        return

n= int(input())
A = [int(a) for a in input().split()]
c = 0
print_sub(A, n-1, c)

print("0")


### FIXED CODE ###

import sys
input = sys.stdin.readline

n = int(input())
A = [int(a) for a in input().split()]

sub_list = [0] *n

for a in A:
  sub_list[a-1] +=1

for i in range(n):
  print(sub_list[i])
import math
a, b = map(int, input().split())
print(max(1+int(math.log2(b//a)), 0))


### 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")
# https://atcoder.jp/contests/aising2019/tasks/aising2019_c

H, W = map(int, input().split())
M = [list(input()) for _ in range(H)]
seen = [[False] * W for _ in range(H)]


def dfs(h, w, ph, pw, color):
    nc = "." if color == "#" else "#"
    bc, bw = 0, 0
    if color == '#':
        bc += 1
    if color == '.':
        bw += 1
    
    path = []
    for (dh, dw) in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
        nh, nw = h + dh, w + dw
        if nh < 0 or H <= nh or nw < 0 or W <= nw:
            continue
        if nh == ph and nw == pw:
            continue
        if seen[nh][nw]:
            continue
        if M[nh][nw] != nc:
            continue

        seen[nh][nw] = True
        b_add, w_add = dfs(nh, nw, h, w, nc)
        bc += b_add
        bw += w_add
    return bc, bw

ans = 0
for h in range(H):
    for w in range(W):
        if seen[h][w] == False:
            seen[h][w] = True
            (b, w) = dfs(h, w, -1, -1, M[h][w])
            ans += b * w
print(ans)

### FIXED CODE ###

# https://atcoder.jp/contests/aising2019/tasks/aising2019_c

import sys
sys.setrecursionlimit(10 ** 7)

H, W = map(int, input().split())
M = [list(input()) for _ in range(H)]
seen = [[False for _ in range(W)] for _ in range(H)]


def dfs(h, w, ph, pw):
    if M[h][w] == '.':
        bc, wc = 0, 1
    else:
        bc, wc = 1, 0
    for (dh, dw) in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
        nh, nw = h + dh, w + dw
        if nh < 0 or H <= nh or nw < 0 or W <= nw:
            continue
        if nh == ph and nw == pw:
            continue
        if seen[nh][nw]:
            continue
        if M[nh][nw] == M[h][w]:
            continue
        seen[nh][nw] = True
        b_add, w_add = dfs(nh, nw, h, w)
        bc += b_add
        wc += w_add
    return bc, wc

ans = 0
for h in range(H):
    for w in range(W):
        if seen[h][w] == False:
            seen[h][w] = True
            b, w = dfs(h, w, -1, -1)
            ans += b * w
print(ans)
S = input()
T = S.replace("*","x")[
print(T)


### FIXED CODE ###

S= input()
t= len(S)
print("x" * t)
a = int(input())
s = int(input())

if a >= 3200:
	print(s)
else:
	print('red')a = int(input())
s =input()

if a >= 3200:
	print(s)
else:
	print('red')

### FIXED CODE ###

a = int(input())
s =input()

if a >= 3200:
	print(s)
else:
	print('red')
n,l,t=map(int,input().split())
inf=[]
s=0
for _ in range(n):
x,y=map(int,input().split())
   if y==1:
       x+=t
   else:
       x-=t
    inf.append(x%l)
    s+=x//l
inf.sort()
s%n
for i in range(n):
    print(inf[(i+p)%n])

### FIXED CODE ###

n,l,t=map(int,input().split())
inf=[]
s=0
for _ in range(n):
   x,y=map(int,input().split())
   if y==1:
       x+=t
   else:
       x-=t
   inf.append(x%l)
   s+=x//l
inf.sort()
for i in range(n):
    print(inf[(i+s)%n])
K = input()
(A, B) = map(int, input.split())
buf = True
for i in range(A, B + 1):
  if(i % K == 0):
    print("OK")
	return 
print("NG")

### FIXED CODE ###

K = int(input())
(A, B) = map(int, input().split())
buf = True
for i in range(A, B + 1):
  if(i % K == 0):
    print("OK")
    buf = False
    break
if buf:
  print("NG")
number = int(input)
print("ABC" + str(number))

### FIXED CODE ###

number =input()
print("ABC" + number)
L,R = map(int,input().split())
right = min(L+2019, R+1)
minumum = 2019

for i in range(L,right):
    for j in range(i+1,right):
         minimum = min(minimum,(i*j) % 2019)

print(minimum)

### FIXED CODE ###

L,R = map(int,input().split())
right = min(L+2019, R+1)
minimum = 2019

for i in range(L,right):
    for j in range(i+1,right):
         minimum = min(minimum,(i*j) % 2019)

print(minimum)
s = input()
s.sort()
ans = "No"
if s[0] == s[1] and s[2] == s[3]:
    if s[1] != s[2]:
        ans = "Yes"
print(ans)


### FIXED CODE ###

s = list(input())
s.sort()
ans = "No"
if s[0] == s[1] and s[2] == s[3]:
    if s[1] != s[2]:
        ans = "Yes"
print(ans)
# -*- coding: utf-8 -*-

s1 = int(raw_input())
s2 = int(raw_input())
if s1>s2:
    print "GREATER"
elif s1 == s2:
    print "EQUAL"
else:
    print "LESS

### FIXED CODE ###

s1 = int(raw_input())
s2 = int(raw_input())
if s1>s2:
    print "GREATER"
elif s1 == s2:
    print "EQUAL"
else:
    print "LESS"
3 1
4 1 5

### FIXED CODE ###

n,k = map(int,input().split())
H = list(map(int,input().split()))
H.sort()
if k>=n:
    print(0)
else:
    print(sum(H[0:n-k]))
from fractions import math
n = int(input())
a = list(map(int, input().split()))
min_mod = min(a)
flag = True
b = math.gcd(a[0], a[1])
for i in range(2, n):
    b = math.gcd(a[i], b)
print(b)

### FIXED CODE ###

from fractions import gcd
n = int(input())
a = list(map(int, input().split()))
flag = True
b = gcd(a[0], a[1])
for i in range(2, n):
    b = gcd(a[i], b)
print(b)
n, m = map(int, input().split())
A = [int(input()) for _ in range(m)]
mod = 1000000007

B = ['.'] * (n + 1)
for a in A:
    B[a] = '#'
    
dp = [0] * (n + 1)
if B[1] == '.' and B[2] == '.':
    dp[1] = 1
    dp[2] = 2
elif B[1] == '#' and B[2] == '.':
    dp[2] = 1
elif B[1] == '.' and B[2] == '#':
    dp[1] = 1
    
for i in range(3, n + 1):
    if B[i] == '.':
        dp[i] = (dp[i - 2] + dp[i - 1]) % mod
    
print(1 if n == 1 else dp[-1])

### FIXED CODE ###

import sys
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
mod = 10 ** 9 + 7

if N == 1:
    print(1)
    sys.exit()

B = ['.'] * (N + 1) 
for a in A:
    B[a] = '#'
    
dp = [0] * (N + 1)
if B[1] == '.' and B[2] == '.':
    dp[1] = 1
    dp[2] = 2
elif B[1] == '#' and B[2] == '.':
    dp[2] = 1
elif B[1] == '.' and B[2] == '#':
    dp[1] = 1
    
for i in range(3, N + 1):
    if B[i] == '.':
        dp[i] = (dp[i - 2] + dp[i - 1]) % mod
    
print(dp[N])
n, i = map(int,input.split())
print(n-i+1)

### FIXED CODE ###

n, i = map(int,input().split())
print(n-i+1)
N = int(input())
A = list(map(int, input().split()))

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

ans = A[0]
for i in range(n):
    ans = gcd(ans, A[i])

    print(ans)

### FIXED CODE ###

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

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

ans = A[0]
for i in range(N):
    ans = gcd(ans, A[i])

print(ans)
S = input()
T = input()

for i in range(len(S) - len(T) + 1):
    flag = True
    for j in range(len(T)):
        if S[i+j] != T[j]:
            flag = False
    if flag:
        break
            
if flag:
    res = ''
    for i in range(len(S)):
        if S[i] == '?':
            res += 'a'
        else:
            res += S[i]
            
    print(res)
    
else:
    tmp = -1
    for i in range(len(S) - len(T) + 1):
        start = -1
        for j in range(len(T)):
            if S[i+j] == T[j] or S[i+j] == '?':
                start = i
            else:
                start = -1
                break
                
        
        if start != -1:
                tmp = i
if tmp == -1:
    print('UNRESTORABLE')
else:
    res = ''
    count = 0
    for i in range(len(S)):
        if start <= i <= start + len(T):
            res += T[count]
            count += 1
        elif S[i] == '?':
            res += 'a'
        else:
            res += S[i]
            
    print(res)
                
            

### FIXED CODE ###

S = input()
T = input()


    
if True:
    tmp = -1
    for i in range(len(S) - len(T) + 1):
        start = -1
        for j in range(len(T)):
            if S[i+j] == T[j] or S[i+j] == '?':
                start = i
            else:
                start = -1
                break
                
        
        if start != -1:
                tmp = i
    if tmp == -1:
        print('UNRESTORABLE')
    else:
        res = ''
        count = 0
        for i in range(len(S)):
            if tmp <= i < tmp + len(T):
                res += T[count]
                count += 1
            elif S[i] == '?':
                res += 'a'
            else:
                res += S[i]

        print(res)
n = int(input())
c = 0

def devisor(n):
    if n == 2:
        return 1
    else:
        if n < 2 or n % 2 == 0:
            return 0
        elif pow(2,n-1,n) == 1:
            return 1

for i in range(n):
    x = int(input())
    c += devisor(x)

print(c)

### FIXED CODE ###

n = int(input())
c = 0

def devisor(n):
    if n == 2:
        return 1
    else:
        if n < 2 or n % 2 == 0:
            return 0
        elif pow(2,n-1,n) == 1:
            return 1
        else: return 0

for i in range(n):
    x = int(input())
    c += devisor(x)

print(c)
while True:
    e = int(input().strip())
    if e == 0:
        break
    
    m = e + 1
    y = 0
    while y ** 2 <= e:
        z = 0
        while y ** 2 + z ** 3 <= e:
            x = e - y ** 2 - z ** 3
            m = min(m, x + y + z)
            z += 1
        y += 1
    print(m)



### FIXED CODE ###

import math

while True:
    e = int(input())
    if e == 0:
        break
    
    m = e + 1
    z = 0
    while z <= e:
        z3 = z ** 3
        if z3 > e:
            break
        y = int(math.sqrt(e - z3))
        x = e - y ** 2 - z3
        m = min(m, x + y + z)
        z += 1
    print(m)
def main():
    n = int(input())
    on = n
    def is_prime(n):
        for i in range(2, n + 1):
            if i * i > n:
                break
            if n % i == 0:
                return False
        return n != 1
    if is_prime(n):
        print(1)
        sys.exit()

    nn = ceil(n**0.5)
    nn = max(6, nn)
    p = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(nn + 1)]
    p[0] = p[1] = False
    p[2] = p[3] = p[5] = True
    for i1 in range(3, floor(nn ** 0.5) + 1, 2):
        if p[i1]:
            for i2 in range(i1 ** 2, nn + 1, i1):
                p[i2] = False
        else:
            continue
    pl = [i for i, b in enumerate(p) if b == True]

    nums = deepcopy(pl)
    for pe in pl:
        cnt = 2
        while True:
            tnum = pow(pe, cnt)
            if tnum > n:
                break
            elif tnum != 0:
                if n % tnum == 0:
                    nums.append(tnum)
            cnt += 1

    nums.sort()
    numsd = deque(nums)
    ok = set()
    r = 0
    while True:
        if not numsd:
            break
        if n == 1:
            break
        nextn = numsd.popleft()
        if nextn > on or nextn > n:
            break
        elif n % nextn == 0:
            if nextn in ok:
                continue
            else:
                n = int(n // nextn)
                ok.add(nextn)
                r += 1
        if n == 1:
            break


    print(r)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
from collections import Counter
def main():
    n = int(input())

    def is_prime(n):
        for i in range(2, n + 1):
            if i * i > n:
                break
            if n % i == 0:
                return False
        return n != 1

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


    if is_prime(n):
        print(1)
        sys.exit()

    pd = prime_dec(n)
    pdc = Counter(pd)
    pdcl = [pdc[i] for i in pdc]
    r = 0
    for pse in pdcl:
        num = pse
        cnt = 1
        while num > 0:
            if cnt > num:
                break
            else:
                r += 1
                num -= cnt
                cnt += 1
    print(r)


if __name__ == '__main__':
    main()
def datesOfTheYear(year):
    if year % 3 == 0:
        return 200
    return 195


def datesOfTheMonth(year, month):
    if year % 3 == 0:
        return 20
    if month % 2 == 0:
        return 19
    else:
        return  20


def datesFromBorn(birthyear, birthmonth, birthdate):
    result = 0
    for y in range(birthyear + 1, 1000):
        result += datesOfTheYear(y)
    for m in range(birthmonth + 1, 11):
        result += datesOfTheMonth(birthyear, m)
    result += datesOfTheMonth(birthyear, birthmonth) - birthdate + 1
    return result                                                 


if __name__ == "__main__":
    import sys
    import fileinput

    fin = fileinput.input()
    numberofcandidate = int(fin.next().sprit())

    for _ in range(numberofcandidate):
        year, month, date = fin.next().strip().split()
        print datesFromBorn(year, month, date)

    sys.exit(0)

### FIXED CODE ###

def datesOfTheYear(year):
    if year % 3 == 0:
        return 200
    return 195


def datesOfTheMonth(year, month):
    if year % 3 == 0:
        return 20
    if month % 2 == 0:
        return 19
    else:
        return  20


def datesFromBorn(birthyear, birthmonth, birthdate):
    result = 0
    for y in range(birthyear + 1, 1000):
        result += datesOfTheYear(y)
    for m in range(birthmonth + 1, 11):
        result += datesOfTheMonth(birthyear, m)
    result += datesOfTheMonth(birthyear, birthmonth) - birthdate + 1
    return result

if __name__ == "__main__":
    import sys
    import fileinput

    fin = fileinput.input()
    numberofcandidate = int(fin.next().strip())

    for _ in range(numberofcandidate):
        year, month, date = [int(i) for i in fin.next().strip().split()]
        print datesFromBorn(year, month, date)

    sys.exit(0)
#input
import numpy as np
N, K = map(int, input().split())
A = np.array(list(map(int, input().split())))

#output
A = np.sort(A)

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

q = np.full(N, 0)
for i in range(N-K+1):
    q[i] = cmb(N-i-1, N-K-i)

r = -q + np.flip(q)

print((A*r).sum() % (10**9 + 7))

### FIXED CODE ###

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

#output
import math

A.sort()
mod = 10**9+7

n_ = 10**5 + 3
fun = [1]*(n_+1)
for i in range(1,n_+1):
    fun[i] = fun[i-1]*i%mod
rev = [1]*(n_+1)
rev[n_] = pow(fun[n_],mod-2,mod)
for i in range(n_-1,0,-1):
    rev[i] = rev[i+1]*(i+1)%mod
def cmb(n,r):
    if n <= 0 or r < 0 or r > n: return 0
    return fun[n]*rev[r]%mod*rev[n-r]%mod
#これだとTLE!
"""
def cmb(n, r):
    if n < r: return 0
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result
"""

M = 0
m = 0
for i, a in enumerate(A):
    M += cmb(i, K-1) * a
    m += cmb(N-i-1, K-1) * a
    M %= mod
    m %= mod

print((M-m) % mod)
N=int(input())
V=list(map(int,input().split))
C=list(map(int,input().split))
mouke=0
for i in range(N):
    adv=V[i]-C[i]
    if adv>0:
        mouke+=adv:
print(mouke)

### FIXED CODE ###

N=int(input())
V=list(map(int,input().split()))
C=list(map(int,input().split()))
mouke=0
for i in range(N):
    adv=V[i]-C[i]
    if adv>0:
        mouke+=adv
print(mouke)
str = input()
n = len(str)
a = str[:n//2]
b = str[n//2+1:][::-1]
count = 0
for i in range(0,n//2):
  if a[i]!=b[i]:
    count+=1
print(count)

### FIXED CODE ###

str = input()
n = len(str)
a = str[:n//2]
b = str[n//2+n%2:][::-1]
count = 0
for i in range(0,n//2):
  if a[i]!=b[i]:
    count+=1
print(count)
N=int(input())
a=N%10
if a<10:
	if a==2 or a==4 or a==5 or a==7 or a==9:
    	print("hon")
    else if a==0 or a==1 or a==6 or a==8:
    	print("pon")
    else:
    	print("bon")


        
     
	

### FIXED CODE ###

def cal():

    num = int(input())
    if num >= 10:
        ben = num % 10
    else:
        ben = num
    
    if ben == 3:
        print("bon")
    elif ben == 0 or ben == 1 or ben == 6 or ben == 8:
        print("pon")
    elif ben == 2 or ben == 4 or ben == 5 or ben == 7 or ben == 9:
        print("hon")
    


cal()