Harryxun/stf_run huggingface dataset:
import sys
import re
import math
import collections
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===

def main():
    x, y, z, w = ns()
    a = na()
    b = na()
    c = na()

    a.sort(reverse=True)
    b.sort(reverse=True)
    c.sort(reverse=True)

    ans = []
    lim = 3333
    for i in range(x):
        if x > lim:
            break
        for j in range(y):
            if x * y > lim:
                break
            for k in range(z):
                if x * y * z > lim:
                    break
                ans.append(a[i] + b[j] + c[k])
                
    ans.sort(reverse=True)

    for i in range(w):
        print(ans[i])


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import re
import math
import collections
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===

def main():
    x, y, z, w = ns()
    a = na()
    b = na()
    c = na()

    a.sort(reverse=True)
    b.sort(reverse=True)
    c.sort(reverse=True)

    ans = []
    for ai in a:
        for bi in b:
            ans.append(ai + bi)

    ans.sort(reverse=True)
    ans = ans[:3010]

    res = []
    for ci in c:
        for i in range(len(ans)):
            res.append(ci + ans[i])
    res.sort(reverse=True)

    for i in range(w):
        print(res[i])


if __name__ == '__main__':
    main()
print(int(input() // 3)


### FIXED CODE ###

print(int(input()) // 3)
yen = int(input())
'''
happy= 0
while yen > 499:
  yen -= 500
  happy += 1000

while yen > 4:
  yen -=5
  happy += 5
'''
happy = 1000 * int(yen//500) + 5 * int((yen - (500 * int(yen//500)))//5)

print(hap)py)


### FIXED CODE ###

yen = int(input())
'''
happy= 0
while yen > 499:
  yen -= 500
  happy += 1000

while yen > 4:
  yen -=5
  happy += 5
'''
happy = 1000 * int(yen//500) + 5 * int((yen - (500 * int(yen//500)))//5)

print(happy)
import math
N=int(input())
C=0
 
for l in range(N):
    for n in range(N):
        for m in range(N):
            if l==0 or m==0 or n==0:
                C+=1
            else:
                C+=math.gcd(math.gcd(l+1,m+1),n+1)
 
print(C

### FIXED CODE ###

import math
N=int(input())
C=0
 
for l in range(N):
    for n in range(N):
        for m in range(N):
            if l==0 or m==0 or n==0:
                C+=1
            else:
                C+=math.gcd(math.gcd(l+1,m+1),n+1)
 
print(C)
# 再帰関数で作る木の個数を返す
def dfs(now, end, summary):
    # 終了条件
    if now == end:
        return summary
    # 1つ前の頂点時点で作ることのできる木の個数 *（現在の深さ ^ その深さの頂点の数）で再帰関数
    else:
        return dfs(now + 1, end, summary * (now ** deep[now]))

# 最後に割る数の定数
JOSU = 998244353

# 入力
N = int(input())
D = list(map(int, input().split()))

# 深さをメモするため、Dの最大値 + 1の数の配列を用意
# 例：深さの最大が2なら、0, 1, 2の3つが必要
deep = [0] * (max(D) + 1)

# 各深さの頂点の数を記録
for i in range(N):
    deep[D[i]] += 1

# 深さ0の頂点が1以外なら、木ができないため0を返す
if deep[0] != 1:
    print(0)
# 深さ0の頂点のみなら、1を返す
elif len(deep) == 1:
    print(1)
# それ以外なら各深さの辺のつけ方を計算して返す
else:
    print(dfs(1, len(deep), 1) % JOSU)



### FIXED CODE ###

# 再帰関数の最大再帰回数を変更
import sys
sys.setrecursionlimit(1000000)

# 再帰関数で作る木の個数を返す
def dfs(now, end, summary):
    # 終了条件
    if now == end:
        return summary
    # 1つ前の頂点時点で作ることのできる木の個数 *（１つ前の深さの頂点の数 ^ 現在の深さの頂点の数）で再帰関数
    else:
        return dfs(now + 1, end, summary * (deep[now - 1] ** deep[now]))

# 最後に割る数の定数
JOSU = 998244353

# 入力
N = int(input())
D = list(map(int, input().split()))

# 深さをメモするため、Dの最大値 + 1の数の配列を用意
# 例：深さの最大が2なら、0, 1, 2の3つが必要
deep = [0] * (max(D) + 1)

# 各深さの頂点の数を記録
for i in range(N):

    # 頂点1が深さ0以外なら制約違反
    if i == 0 and D[i] != 0:
        print(0)
        exit()
    # 頂点1以外が深さ0なら制約違反
    elif i > 0 and D[i] == 0:
        print(0)
        exit()

    deep[D[i]] += 1

# 再帰関数で計算
print(dfs(1, len(deep), 1) % JOSU)
n=int(input())
a=0
for i in range(2):
  if n[i]==n[i+1] and n[i+1]==n[i+2]:
    a=1
print(["No","Yes"][a])

### FIXED CODE ###

n=input()
a=0
for i in range(2):
  if n[i]==n[i+1] and n[i+1]==n[i+2]:
    a=1
print(["No","Yes"][a])
# coding: utf-8

numbers=input().rstrip().split(" ")

num=0
s=int(numbers[0])
c=int(numbers[1])

while c>=2:
    if s>=1 and c>=2:
        num+=1
        s-=1
        c-=2
    
    elif  c>=2:
        s+=1
        c-=2

print(num)




### FIXED CODE ###

# coding: utf-8
# Here your code !
N=int(input())
x=800*N
y=(N//15)*200

print(x-y)
import sys

def my_index(l, x):
    if x in l:
        return l.index(x)
    else:
        return -1

input = sys.stdin.readline
n,m = map(int, input().split())
A = list(map(int,input().split()))

for j in range(m):
    A.sort()
    b,c = map(int, input().split())
    if b <= n:
        if A[b] > c:
            for i in range(c):
                if A[0] < c-i:
                    f = my_index(A, c-i)
                    if f != -1:
                        A[:f]=[c]*f
                        break
                else:
                    break
        else:
            A[:b]=[c]*b


print(sum(A))

### FIXED CODE ###

import sys
import heapq

input = sys.stdin.readline
n,m = map(int, input().split())
A = list(map(int,input().split()))
d = [list(map(int,input().split())) for _ in range(m)]

d.sort(key=lambda x:-x[1])
total = sum(A)
heapq.heapify(A)

for i in range(m):
    for j in range(d[i][0]):
        tmp = heapq.heappushpop(A, d[i][1])
        if tmp < d[i][1]:
                total += (d[i][1] - tmp)
        else:
            break

print(total)
N = int(input())
mn = 10**9 + 1
mx = 0
mnj = None
mxj = None
for i in range(N):
    Ai,Bi = map(int, input().split())
    if mn > Bi:
        mn = Bi
        mnj = Ai
    if mx < Bi:
        mx = Bi
        mxj = Ai
print(mxj + mnj - mxj + mn)

### FIXED CODE ###

N = int(input())
mn = 10**9 + 1
mx = -1
mnj = 10**9 + 1
mxj = -1
for i in range(N):
    Ai,Bi = map(int, input().split())
    if mn > Bi:
        mn = Bi
        mnj = Ai
    if mx < Bi:
        mx = Bi
        mxj = Ai
print(mxj + mnj - mxj + mn)
x,y = map(int,input().split())
list = [input() for i in range(x)]

if list[0]<list[1] and list[0]<list[2]:
    if list[1]<list[2]:
        print(list[0]+list[1]+list[2])
    else:
        print(list[0]+list[2]+list[1])

if list[1]<list[0] and list[1]<list[2]:
    if list[0]<list[2]:
        print(list[1]+list[0]+list[2])
    else:
        print(list[1]+list[2]+list[0])

if list[2]<list[0] and list[2]<list[1]:
    if list[0]<list[1]:
        print(list[2]+list[0]+list[1])
    else:
        print(list[2]+list[1]+list[0])


### FIXED CODE ###

go=0
nana=0
num = input().split()
for i in num:
  if i == "5":
    go+=1
  if i == "7":
    nana+=1
if (go==2) and (nana==1):
  print("YES")
else:
  print("NO")
from collections import Counter
N = int(input())
D = list(map(int,input().split()))
M = int(input())
T = list(map(int,input().split()))
Tcount = Counter(T)
flag = 'YES'
Dcount = Counter(D)
for n,c in Tcount.items():
    if n not in D:
        flag = 'NO'
        break
    if c > D[n]:
        flag = 'NO'
        break
print(flag)

### FIXED CODE ###

from collections import Counter
N = int(input())
D = list(map(int,input().split()))
M = int(input())
T = list(map(int,input().split()))
Tcount = Counter(T)
flag = 'YES'
Dcount = Counter(D)
for n,c in Tcount.items():
    if n not in Dcount:
        flag = 'NO'
        break
    if c > Dcount[n]:
        flag = 'NO'
        break
print(flag)
a,b=map(int,input().split())
s = [input().strip("\"") for i in range(a)]
print("".join(s)) 

### FIXED CODE ###

a=list(map(int,input().split()))
a.sort() 
if a==[5,5,7]:
  print("YES")
else:
    print("NO")
def visiting(values,hp,vp,item):
	if not (0<=hp<len(values)): return
	if not (0<=vp<len(values[hp])): return
	if item!=values[hp][vp]: return
	values[hp][vp]=True
	visiting(values,hp-1,vp,item)
	visiting(values,hp+1,vp,item)
	visiting(values,hp,vp-1,item)
	visiting(values,hp,vp+1,item)

def solve(values):
	count=0
	for i in range(len(values)):
		for j in range(len(values[i])):
			if values[i][j] in ['@','#','*']:
				visiting(values,i,j,values[i][j])
				count+=1
	return count

def main():
	line,values=input(),list()
	while line!='0 0':
		H,W = list(map(int,line.strip().split(' ')))
		value = list()
		for _ in range(H):
			value.append(list(x for x in input().strip()))
		values.append(value)
		line = input()
	for value in values:
		print(solve(value))

if __name__=='__main__':
	main()

### FIXED CODE ###

# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10**6)

def search(field,hp,vp,item):
	if not (0<=hp<len(field)): return
	if not (0<=vp<len(field[hp])): return
	if item!=field[hp][vp]: return
	field[hp][vp]=True
	for dh,dv in [[0,1],[0,-1],[1,0],[-1,0]]:
		search(field,hp+dh,vp+dv,item)
#	search(field,hp-1,vp,item)
#	search(field,hp+1,vp,item)
#	search(field,hp,vp-1,item)
#	search(field,hp,vp+1,item)

def solve(field):
	count,valid_items=0,set(['@','#','*'])
	for i in range(len(field)):
		for j in range(len(field[i])):
			if field[i][j] in valid_items:
				search(field,i,j,field[i][j])
				count+=1
	return count

def main():
	line = input().strip()
	while line!='0 0':
		H,W = list(map(int,line.split(' ')))
		field = list()
		for _ in range(H):
			field.append(list(input().strip()))
		print(solve(field))
		line = input().strip()

if __name__=='__main__':
	main()
H,W = sorted(map(int,input().split()))
ss=[]
for s in range(H):
    ss.append(input().strip())
flg=True
for i in range(H):
    for j in range(W):
        if ss[i][j]== "#":
            if not (j>0 and ss[i][j-1] == "#"or j<W-1 and ss[i][j+1] == "#" or i>0 and ss[i-1][j]=="#" or i< H-1 and ss[i+1][j]=="#"):
                flg=False
                break
    if not flg:
        break
print("No Yes".split()[int(flg)])  

### FIXED CODE ###

H,W = map(int,input().split())
ss=[]
for s in range(H):
    ss.append(input().strip())
flg=True
for i in range(H):
    for j in range(W):
        if ss[i][j]== "#":
            if not (j>0 and ss[i][j-1] == "#"or j<W-1 and ss[i][j+1] == "#" or i>0 and ss[i-1][j]=="#" or i< H-1 and ss[i+1][j]=="#"):
                flg=False
                break
    if not flg:
        break
print("No Yes".split()[int(flg)])
a, b = map(int, input())
if a % b == 0:
    print(a + b)
else:
    print(b - a)

### FIXED CODE ###

a, b = map(int, input().split())
if b % a == 0:
    print(a + b)
else:
    print(b - a)
nm = input().split(" ")
n = int(nm[0])
m = int(nm[1])

pars = [-1]*n

def get_root(x):
    if pars[x] < 0:
        return x
    else:
        return get_root(pars[x])


def combine(x, y):
    if x == y:
        return
    r_x = get_root(x)
    r_y = get_root(y)
    if r_x > r_y:
        r_x, r_y = r_y, r_x
    if r_x != r_y:
        pars[r_x] += pars[r_y] # 足して経路長を求めるのに使う
        pars[r_y] = r_x

def size(x):
    return -pars[get_root(x)]

for i in range(m):
    pair = input().split(" ")
    x = int(pair[0]) - 1 # 入力が1スタートなので
    y = int(pair[1]) - 1 # 入力が1スタートなので
    combine(x, y)

max_len = 0
for i in range(n):
    len = size(i)
    if len > max_len:
        max_len = len

print(max_len)


### FIXED CODE ###

import sys


class UnionFind():
    def __init__(self, n):
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x


N, M = map(int, input().split())
info = [tuple(map(int, s.split())) for s in sys.stdin.readlines()]

uf = UnionFind(N)
for a, b in info:
    a -= 1; b -= 1
    uf.union(a, b)

ans = min(uf.parents)

print(-ans)
for i in range(1,N//4):
    if (N//i) == N%i:
        ans += i
for i in range(N//4,N//3):
    if (N//i) == N%i:
        ans += i
for i in range(N//3,N//2):
    if (N//i) == N%i:
        ans += i
for i in range(N//2,N):
    if (N//i) == N%i:
        ans += i
print(ans)

### FIXED CODE ###

import math
def prime_divisor(n):
    ls = []
    i = 2
    while i <= math.floor(n**0.5):
        if n%i == 0:
            ls.append(i)
            ls.append(n//i)
            i += 1
        else:
            i += 1
    if n > 1:
        ls.append(n)
    return ls
N = int(input())
ls1 = prime_divisor(N)
ls2 = [x-1 for x in list(set(ls1)) if x >= 2]
ls2.sort()
ls2.reverse()
ans = 0
for i in range(len(ls2)):
    if N // ls2[i] == N % ls2[i]:
        ans += ls2[i]
print(ans)
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

def main():
    q = int(input())
    for _ in range(q):
        a, b = map(int, input().split())
        c = a * b - 1
        rc = int(c ** 0.5)
        ans = rc * 2
        if c // rc == rc:
            ans -= 1
        ab = set([a, b])
        for a in ab:
            ans -= 1
            if a > rc:
                y = rc // a
                if y == 0:
                    ans += 1
                else:
                    x = rc // y
                    if x != a or (c // a == c // (a - 1)):
                        ans += 1
        print(ans)

main()


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

def main():
    def df(c, d):
        res = c // d
        if res * d > c: res -= 1
        return res

    q = int(input())
    L = [list(map(int, input().split())) for _ in range(q)]
    for a, b in L:
        if (a, b) == (1, 1):
            print(0)
            continue
        c = a * b - 1
        rc = int(c ** 0.5)
        rc -= 1
        while (rc + 1) ** 2 <= c:
            rc += 1
        ans = rc * 2
        if rc * (rc + 1) > c:
            ans -= 1
        ab = [a, b]
        for k in ab:
            ans -= 1
            if k > rc:
                y = df(c, k)
                if y == 0:
                    ans += 1
                else:
                    x = df(c, y)
                    if x != k or (df(c, k) == df(c, k - 1)):
                        ans += 1
        print(ans)

main()
def resolve():
    from math import log2
    n=int(input())
    S=sorted(list(map(int,input().split())), reverse=True)
    flag = True
    for i in range(2**(n-1)):
        j=(i+2**(int(log2(i)+1))) if i!=0 else 1
        if S[i]<=S[j]:
            flag = False
            break
    print("Yes" if flag else "No")
resolve()

### FIXED CODE ###

import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    N=1<<n
    s=list(map(int,input().split()))
    s.sort(reverse=1)
    p=[s[0]]
    s[0]=INF
    for _ in range(n):
        p.sort(reverse=1)
        q=p[:]
        idx=0
        for i in q:
            while(idx!=N):
                j=s[idx]
                idx+=1
                if(i<=j): continue
                p.append(j)
                s[idx-1]=INF
                break
    print("Yes" if len(p)==N else "No")
resolve()
N = int(input())
A = list(map(int, input().split()))
MOD = 10**9 + 7

ans = 1
num_color = [-1, -1, -1]
for a in A:
  ans = (ans * num_color.count(a-1)) % MOD
  num_color[num_color.index(a-1)] = a

print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
MOD = 10**9 + 7

ans = 1
num_color = [-1, -1, -1]
for a in A:
  ans = (ans * num_color.count(a-1)) % MOD
  try:
    num_color[num_color.index(a-1)] = a
  except:
    print(0)
    quit()

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

if D <= T*S:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

D, T, S = map(int, input().split())

if D <= T*S:
    print("Yes")
else:
    print("No")
K  = int(input())
n = 0
n1 = 0
n2 = 0
n3 = 0
n4 = 0
n5 = 0


#Kが500以下の場合、斜め作戦にする
if K <= 500:
   n = K
   mat = [[0 for n1 in range(K)] for n2 in range(K)]
   for n1 in range(K):
      for n2 in range(K-n1):
         mat[n1][n1+n2] = n2+1
   for n1 in range(K):
      for n2 in range(n1):
         mat[n1][n2] = K+n2-n1+1

#Kが500以上の場合、斜めに1マスずつしのびこませる   
else:
   n = 500
   mat = [[0 for n1 in range(500)] for n2 in range(500)]
   for n1 in range(500):
      for n2 in range(500-n1):
         mat[n1][n1+n2] = n2+1
   for n1 in range(500):
      for n2 in range(n1):
         mat[n1][n2] = 500+n2-n1+1










#行列の出力かんがえとく 
print(n)
out = ""
for n1 in range(K):
   out = ""   
   for n2 in range(K):
      out = out + " " + str(mat[n1][n2])
   print(out)





### FIXED CODE ###

K  = int(input())
n = 0
n1 = 0
n2 = 0
n3 = 0
n4 = 0
n5 = 0


#Kが500以下の場合、斜め作戦にする
if K <= 499:
   n = K
   mat = [[0 for n1 in range(K)] for n2 in range(K)]
   for n1 in range(K):
      for n2 in range(K-n1):
         mat[n1][n1+n2] = n2+1
   for n1 in range(K):
      for n2 in range(n1):
         mat[n1][n2] = K+n2-n1+1

#Kが500以上の場合、斜めに1マスずつしのびこませる   
else:
   n = 500
   mat = [[0 for n1 in range(500)] for n2 in range(500)]
   for n1 in range(500):
      for n2 in range(500-n1):
         mat[n1][n1+n2] = n2+1
   for n1 in range(500):
      for n2 in range(n1):
         mat[n1][n2] = 500+n2-n1+1

   #Kが500以上の場合のギザギザ部分
   for n2 in range(K-500):
      for n1 in range(250):
          kari = n1*2+n2
          if kari >= 500:
             kari = kari-500
          mat[n1*2][kari] = n2+501


#行列の出力かんがえとく 
print(n)

if K <= 500:
   out = ""
   for n1 in range(K):
      out = ""   
      for n2 in range(K):
         out = out + " " + str(mat[n1][n2])
      print(out)
   
#Kが500以上の場合、斜めに1マスずつしのびこませる   
else:
   out = ""
   for n1 in range(500):
       out = ""   
       for n2 in range(500):
          out = out + " " + str(mat[n1][n2])
       print(out)
import math
R = int(input())
print(R * 2 * math.PI)

### FIXED CODE ###

import math
R = int(input())
print(R * 2 * math.pi)
N,K=map(int,input().split())
H=list[map(int,input().split())]
count=0
for h in H:
  if h>=K:
  count=count+1
print(count)

### FIXED CODE ###

N, K = map(int, input().split())
H = list(map(int, input().split()))
count = 0
for h in H:
    if h >= K:
        count = count+1
print(count)
N = input()
nums = list(map(int, input().split()))
cnt = 0
cntlst = []
for i in range (0,N-1):
    taisyouN = nums[i]
    while taisyouN %2 == 0:
        taisyouN = taisyouN/2
        cnt = cnt+1
print(cnt)

### FIXED CODE ###

N = int(input())
nums = list(map(int, input().split()))
cnt = 0
cntlst = []
for i in range(0,N):
    taisyouN = nums[i]
    while taisyouN %2 == 0:
        taisyouN = taisyouN/2
        cnt = cnt+1
    cntlst.append(cnt)
    cnt = 0
print(sum(cntlst))
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


N = I()
s = S()

inf = 10**9+7

from math import factorial
def c(n, r):
    a = factorial(n) / factorial(r) / factorial(n - r)
    return a

result = 0
counts = collections.Counter(s)
red = [i for i in counts.values()]
tmp = 1
for i in red:
    tmp *= i
#  print('tmp', tmp)
for i in range(1, len(s)+1):
    #  print(i)
    #  import pdb
    #  pdb.set_trace()
    #  combis = list(itertools.combinations(counts, i))
    #  print('combis' ,combis)
    result += c(len(s), i)
    #  for combi in combis:
    #      #  print('combi', combi)
    #      tmp = 1
    #      for c in combi:
    #          #  print('c', c)
    #          tmp *= counts[c]
    #      #  print('tmp', tmp)
    #      result += tmp
if tmp != 1:
    for i in range(1, tmp):
        result -= c(tmp, i)
print(int(result)%inf)


### FIXED CODE ###

import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


N = I()
s = S()

inf = 10**9+7

counts = collections.Counter(s)
result = 1
for i in counts.values():
    result *= i+1
result -= 1
print(result%inf)
exit()
mo=10**9+7
def fact(x):
  if x==1:
    return 1
  else:
    return x*fact(x-1)%mo
n,m=map(int,input().split())
if abs(n-m)>1:
  print(0)
elif m==n:
  print((fact(m)*fact(n)*2)%mo)
else:
  print(fact(m)*fact(n)%mo)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
mo=10**9+7
def fact(x):
  if x==0:
    return 1
  else:
    return x*fact(x-1)%mo
n,m=map(int,input().split())
if abs(n-m)>1:
  print(0)
elif m==n:
  print((2*fact(m)*fact(n))%mo)
else:
  print((fact(m)*fact(n))%mo)
# ABC137C - Green Bin
from collections import Counter


def main():
    _, *S = open(0)
    cnt = Counter(sorted(s) for s in S).values()
    ans = sum(i * (i - 1) // 2 for i in cnt)
    print(ans)


if __name__ == "__main__":
    main()

### FIXED CODE ###

# ABC137C - Green Bin
from collections import Counter


def main():
    N = int(input())
    A = Counter("".join(sorted(input())) for _ in range(N))
    ans = sum(i * (i - 1) // 2 for i in A.values())
    print(ans)


if __name__ == "__main__":
    main()
import collections

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

s1 = s[:n]
s2 = s[-1:-(n + 1):-1]

s_1 = collections.defaultdict(int)
s_2 = collections.defaultdict(int)h
for i in range(2 ** n):
    bin_i = bin(i + 2 ** n)
    sequence1 = ""
    sequence1_inverse = ""
    sequence2 = ""
    sequence2_inverse = ""
    for j in range(n):
        if bin_i[j + 3] == "1":
            sequence1 += s1[j]
            sequence2 += s2[j]
        else:
            sequence1_inverse += s1[j]
            sequence2_inverse += s2[j]
    s_1[sequence1 + "-" + sequence1_inverse] += 1     
    s_2[sequence2 + "-" + sequence2_inverse] += 1
ans = 0
for i in dict(s_1):
    ans += s_1.get(i, 0) * s_2.get(i, 0)
    '''
    if i in dict(s_2):
        ans += dict(s_1)[i] * dict(s_2)[i]
    '''
print(ans)


### FIXED CODE ###

import collections

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

s1 = s[:n]
s2 = s[-1:-(n + 1):-1]

s_1 = collections.defaultdict(int)
s_2 = collections.defaultdict(int)

strlist = []

for i in range(2 ** n):
    bin_i = bin(i + 2 ** n)
    sequence1 = ""
    sequence1_inverse = ""
    sequence2 = ""
    sequence2_inverse = ""
    for j in range(n):
        if bin_i[j + 3] == "1":
            sequence1 += s1[j]
            sequence2 += s2[j]
        else:
            sequence1_inverse += s1[j]
            sequence2_inverse += s2[j]
    s_1[sequence1 + "-" + sequence1_inverse] += 1     
    s_2[sequence2 + "-" + sequence2_inverse] += 1
ans = 0

for i in dict(s_1):
    ans += s_1.get(i, 0) * s_2.get(i, 0)
    '''
    if i in dict(s_2):
        ans += dict(s_1)[i] * dict(s_2)[i]
    '''
print(ans)