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

k = n//10

a = k%9
b = (n - 10*k)%9

if a == 0 or b == 0:
  ans = 'Yes'
else:
  ans = 'No'

print(ans)

### FIXED CODE ###

n = int(input())

k = str(n)

#print(k[0])
#print(k[1])

if k[0]=='9' or k[1]=='9' :
	ans = 'Yes'
else:
	ans = 'No'
	
print(ans)
N=int(input())
l1=list(map(int,input().split()))
l2=[]
l3=[]
for i in range(N-1):
  if l1[i]<l1[i+1]:
    l2.append(i)

for i in range(len(l2)-1):
  l3.append(l2[i+1]-l2[i])
print(max(l3))

### FIXED CODE ###

N=int(input())
l1=list(map(int,input().split()))
l1.append(max(l1)+1)
l2=[-1]
l3=[]
for i in range(N):
  if l1[i]<l1[i+1]:
    l2.append(i)
for i in range(len(l2)-1):
  if l2[i+1]-l2[i] >= 2:
    l3.append(l2[i+1]-l2[i]-1)
print(max(l3) if l3 else 0)
def conj(n):
  if n==0:return 1
  return 0

print(conj(int(input()))

### FIXED CODE ###

def conj(n):
  if n==0:return 1
  return 0
print(conj(int(input())))
import sys
from collections import Counter
input = sys.stdin.readline

n = int(input())
s = []
memo = []
ans = ''
for i in range(n):
    s.append(list(input().rstrip('\n')))
    s[i].sort()
    memo.append(list(Counter(s[i]).items()))
for i in range(1, n):
    check = [0] * len(memo[0])
    cnt = 0
    for j in range(len(memo[0])):
        if len(memo[i]) == cnt:
            continue
        memo[i][cnt] = list(memo[i][cnt])
        if memo[0][j][0] == memo[i][cnt][0]:
            if memo[0][j][1] > memo[i][cnt][1]:
                memo[0][j][1] = memo[i][cnt][1]
            cnt += 1
            check[j] = 1
        if check[j] == 0:
            memo[0][j] = list(memo[0][j])
            memo[0][j][1] = 0

for i in range(len(memo[0])):
    for j in range(memo[0][i][1]):
        ans += memo[0][i][0]
print(ans)


### FIXED CODE ###

import sys
from collections import Counter
input = sys.stdin.readline

n = int(input())
s = []
memo = []
ans = ''
check = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
check_cnt = [50] * 26
for i in range(n):
    s.append(list(input().rstrip('\n')))
    s[i].sort()
    memo.append(list(Counter(s[i]).items()))

for i in range(n):
    for check_m in range(26):
        flg = False
        for j in range(len(memo[i])):
            if check[check_m] == memo[i][j][0]:
                if check_cnt[check_m] > memo[i][j][1]:
                    check_cnt[check_m] = memo[i][j][1]
                flg = True
                break
        if flg:
            continue
        else:
            check_cnt[check_m] = 0

for i in range(26):
    for j in range(check_cnt[i]):
        ans += check[i]
print(ans)
H, W, D = map(int, input().split())

A = [list(map(int, input().split())) for i in range(H)]
rA = [[0 for j in range(2)] for i in range(H * W + 1)]
S = [0 for i in range(H * W + 1)]
for i in range(H):
	for j in range(W):
		rA[A[i][j]][0] = i
		rA[A[i][j]][1] = j

Q = int(input())
for i in range(Q):
	L, R = map(int, input().split())
	ans = 0
	for j in range(H * W + 1) [L::D]:
		if j == R:
			break
		if S[j]:
			ans += S[j]
			break
		S[j] -= ans
		ans += abs(rA[j + D][1] - rA[j][1]) + abs(rA[j + D][0] - rA[j][0])
	for j in range(H * W + 1)[L::D]:
		if S[j] > 0:
			break
		S[j] += ans
	print (ans)


### FIXED CODE ###

N = int(input())
print(int(N / 3))
n, m = map(int, input().split())
a = list(map(int, input().split()))

import math
from functools import reduce

# for i, j in enumerate(a):

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

kouyakusuu = gcd_list(a)
koubaisuu = lcm_list(a)

buf = 1
for i, j in enumerate(a):
    buf *= j / kouyakusuu

ans = (m - buf) // koubaisuu + 1

print(int(ans))


### FIXED CODE ###

k, x = map(int, input().split())

if 500*k >= x:
    print("Yes")
else:
    print("No")
n=int(input())
b=list(map(int,input().split()))
a=[]
ans=b[0]
a.append(ans)
for i in range(1,n-1):
    if(b[i] < ans):
        a.append(b[i])
    else:
        a.append(ans)
    ans=b[i]
a.append(b[i])
print(sum(a))

### FIXED CODE ###

n=int(input())
b=list(map(int,input().split()))
a=[]
ans=b[0]
a.append(ans)
#print(n-2)
#exit()
if(n-2==0):
    print(b[0]*2)
    exit()
for i in range(1,n-1):
    if(b[i] < ans):
        a.append(b[i])
    else:
        a.append(ans)
    ans=b[i]
a.append(b[i])
print(sum(a))
n = int(input())
nums = [int(input()) for i in range(n)]
n_max = max(nums)
ex_nums = [i for i in nums].remove(n_max)
n_semi_max = max(ex_nums)
for i in nums:
    if i == n_max:
        print(n_semi_max)
    else:
        print(n_max)

### FIXED CODE ###

n = int(input())
nums = [int(input()) for i in range(n)]
n_max = max(nums)
ex_nums = [i for i in nums]
ex_nums.remove(n_max)
n_semi_max = max(ex_nums)
for i in nums:
    if i == n_max:
        print(n_semi_max)
    else:
        print(n_max)
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=sum(a)
c=sorted(a)
if c[n-m] >=b//(4*m):
  print("Yes")
else:
  print("No")


### FIXED CODE ###

X,Y,Z=map(int,input().split())
print(Z,X,Y)
#! /usr/bin/python3
# こだわり者いろはちゃん / Iroha's Obsession

"""
    1≦N<10000
    1≦K<10
    0≦D1<D2<…<DK≦9
    {D1,D2,…,DK}≠{1,2,3,4,5,6,7,8,9}
"""

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

test_mode = False


def check_num(x, d):
    """
    金額xの中に中の文字があるか確認する関数。
    x : 現在の金額（N, x+1 を想定）
    d : 嫌いな数字のリスト（D を想定）
    文字列 x にリスト d 中の要素が含まれているか、d の要素 num を順に確認し、
    含まれていたら1円足して再試行する。
    """
    if test_mode:
        print('x =', x)
    for num in d:
        str_x = str(x)
        str_num = str(num)
        if str_num in str_x:
            return check_num(x+1, d)
    return x


def main():
    """
    金額を算出して出力
    """
    amount = check_num(N, D)
    print(amount)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#! /usr/bin/python3
# こだわり者いろはちゃん / Iroha's Obsession
# 参考 : https://abc042.contest.atcoder.jp/submissions/3419872

"""
    1≦N<10000
    1≦K<10
    0≦D1<D2<…<DK≦9
    {D1,D2,…,DK}≠{1,2,3,4,5,6,7,8,9}
"""

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

test_mode = False


def check_num(x, d):
    """
    金額xの中に中の文字があるか確認する関数。
    x : 現在の金額（N, x+1 を想定）
    d : 嫌いな数字のリスト（D を想定）
    文字列 x にリスト d 中の要素が含まれているか、d の要素 num を順に確認し、
    含まれていたら1円足して再試行する。
    """
    if test_mode:
        print('x =', x)
    while len(set(list(str(x))) & d) != 0:
        x += 1
    return x


def main():
    """
    金額を算出して出力
    """
    amount = check_num(N, D)
    print(amount)


if __name__ == '__main__':
    main()
N = int(input())
tm_pos = [list(map(int, input().split())) for i in range(N)]
for i in tm_pos:
    if i[0] < i[1] + i[2] or i[0] % 2 != (i[1] + i[2]) % 2:
        print('No')
        exit()
print('Yes')

### FIXED CODE ###

num_list = list(map(int, input().split()))
if (num_list[0] * num_list[1]) % 2 == 1:
    print('Odd')
else:
    print('Even')
print(48-i)
i=int(input())

### FIXED CODE ###

i=int(input())
print(48-i)
from math import sqrt
from decimal import Decimal
ans = [1,2,3]
A,B=map(int,input().split())
ans.remove(A)
ans.remove(B)
print(ans[0])

### FIXED CODE ###

from math import sqrt
from decimal import Decimal
ans = [1,2,3]
A,B=int(input()),int(input())
ans.remove(A)
ans.remove(B)
print(ans[0])
import collections
s=int(input())
count=1
ans=s
prev=0
counter = collections.defaultdict(int)
counter[ans]=1
while(1):
  count+=1
  if ans % 2 == 0:
    ans = ans / 2
  else:
    ans = 3*n+1
    
  if ans not in counter.keys:
    counter[ans]=count
  else:
    print(counter[ans])
    break

### FIXED CODE ###

import collections
s=int(input())
count=1
ans=s
prev=0
counter = collections.defaultdict(int)
counter[ans]=1
while(1):
  count+=1
  if ans % 2 == 0:
    ans = ans / 2
  else:
    ans = 3*ans+1
    
  if ans not in counter.keys():
    counter[ans]=count
  else:
    print(count)
    break
n, m = list(map(int, input().split()))

height = [int(i) for i in input().split()]

tele = {}
for num, h in enumerate(height, 1):
    tele[num] = [h, "G"]

for roads in range(m):
    a, b = list(map(int, input().split()))
    if (tele[a][0] > tele[b][0]):
        tele[b][1] = "N"
    elif (tele[a][0] < tele[b][0]):
        tele[a][1] = "N"
    elif (tele[a][0] == tele[b][0]):
        tele[a][1] = "N"
        tele[b][1] = "N"

ans_list = tele.values()
ans = 0
for a in ans_list:
    if (a[1] == "G"):
        ans += 1

print(ans)



### FIXED CODE ###

t = input()

if (t=="ABC"):
    print("ARC")
else:
    print("ABC")
N,M = list(map(int,input().split()))

e_list = [[] for i in range(N)]

for i in range(M):
    s,t = list(map(int,input().split()))
    s,t = s-1,t-1
    e_list[s].append(t)

DP = [[0] for i in range(N)]
dp0_min = 10**27

for x in range(N-1):
    for i in range(N-1):
        if i==x:
            if len(e_list[N-i-2])==1:
                DP[N-i-2] = DP[e_list[N-i-2][0]]+1
            else:
                max_room = -1
                max_path = 0
                for j in e_list[N-i-2]:
                    if max_path<DP[j]:
                        max_room = j
                        max_path = DP[j]
                    DP[N-i-2] += DP[j]
                DP[N-i-2] -= DP[max_room]
                DP[N-i-2] /= len(e_list[N-i-2])-1
                DP[N-i-2] += 1
        else:
            for j in e_list[N-i-2]:
                DP[N-i-2] += DP[j]
            DP[N-i-2] /= len(e_list[N-i-2])
            DP[N-i-2] += 1
    dp0_min = min(dp0_min,DP[0])
    DP = [[0] for i in range(N)]
print(dp0_min)



### FIXED CODE ###

import sys

def input():
    return sys.stdin.readline()[:-1]

def main():
    N,M = list(map(int,input().split()))

    e_list = [[] for i in range(N)]

    for i in range(M):
        s,t = list(map(int,input().split()))
        s,t = s-1,t-1
        e_list[s].append(t)

    DP = [0]*N
    dp0_min = 10**27

    for x in range(N-1):
        for i in range(N-1):
            if i==x:
                if len(e_list[N-i-2])==1:
                    DP[N-i-2] = DP[e_list[N-i-2][0]]+1
                else:
                    max_room = -1
                    max_path = 0
                    for j in e_list[N-i-2]:
                        if max_path<DP[j]:
                            max_room = j
                            max_path = DP[j]
                        DP[N-i-2] += DP[j]
                    DP[N-i-2] -= DP[max_room]
                    DP[N-i-2] /= len(e_list[N-i-2])-1
                    DP[N-i-2] += 1
            else:
                for j in e_list[N-i-2]:
                    DP[N-i-2] += DP[j]
                DP[N-i-2] /= len(e_list[N-i-2])
                DP[N-i-2] += 1
        dp0_min = min(dp0_min,DP[0])
        DP = [0]*N
    print(dp0_min)

if __name__ == '__main__':
    main()
import sys
sys.setrecursionlimit(10**5)

from collections import defaultdict as dd
n, q = map(int, input().split())
Tree = dd(lambda: [])
for i in range(n-1):
    a, b = map(int, input().split())
    Tree[a].append(b)

Point = dd(lambda: 0)
for i in range(q):
    p, x = map(int, input().split())
    Point[p] += x

Ans = {}
def write(node, point):
    point += Point[node]
    Ans[node] = point
    for next_node in Tree[node]:
        write(next_node, point)
write(1, 0)

for i in range(1, n+1):
    print(Ans[i])

### FIXED CODE ###

from collections import defaultdict as dd
n, q = map(int, input().split())
Connections = dd(list)
for i in range(n-1):
    a, b = map(int, input().split())
    Connections[a].append(b)
    Connections[b].append(a)

#Tree[node] -> children(list)
Tree = dd(list)
visited = set()
stack = [1]
while stack != []:
    temp = []
    for taregt_node in stack:
        for next_node in Connections[taregt_node]:
            if next_node not in visited:
                Tree[taregt_node].append(next_node)
                visited.add(taregt_node)
                temp.append(next_node)
    stack = temp
#print(Tree)

#Point[node] -> point
Point = dd(int)
for i in range(q):
    p, x = map(int, input().split())
    Point[p] += x
#print(Point)

Counter = dd(int)
#visited = set()
stack = [1]
Counter[1] = Point[1]
while stack != []:
    temp = []
    for target_node in stack:
        for next_node in Tree[target_node]:
            Counter[next_node] = Counter[target_node] + Point[next_node]
            temp.append(next_node)
    stack = temp
#print(Counter)

for i in range(1, n):
    print(Counter[i], end=" ")
print(Counter[n])
S=list(input())
a=0
for i in range(1,len(S),2):
    if S[i]=="R" or S[i]=="U" or S[i]=="D":
        a+=1
for j in range(0,len(S),2):
    if S[i]=="L" or S[i]=="U" or S[i]=="D":
        a+=1
if a==len(S):
    print("Yes")
else:
    print("No")

### FIXED CODE ###

S=list(input())
a=0
for j in range(0,len(S),2):
    if S[j]=="R" or S[j]=="U" or S[j]=="D":
        a+=1
for i in range(1,len(S),2):
    if S[i]=="L" or S[i]=="U" or S[i]=="D":
        a+=1
if a==len(S):
    print("Yes")
else:
    print("No")
N=int(input())
a=math.log2(N)
print(round(a))

### FIXED CODE ###

n=int(input())
count=1
while count<=n:
    count=2*count
else:
    print(int(count/2))
Bingo = [ list(map(int,input().split())) for i in range(3)]
n = int(input())
num = [int(input()) for i in range(n)]
Bingo.append([Bingo[0][0] , Bingo[1][1],Bingo[2][2] ])
Bingo.append([Bingo[0][2] , Bingo[1][1],Bingo[2][0] ])
k=0
re = 'No'
for l in range(n):
  if len(list(set(num) & set(Bingo[l]))) == 3:
    re = 'Yes'
    break
print(re)

### FIXED CODE ###

Bingo = [ list(map(int,input().split())) for i in range(3)]
n = int(input())
num = [int(input()) for i in range(n)]
Bingo.append([Bingo[0][0] , Bingo[1][1],Bingo[2][2] ])
Bingo.append([Bingo[0][2] , Bingo[1][1],Bingo[2][0] ])
for k in range(3):
  Bingo.append([Bingo[0][k] , Bingo[1][k],Bingo[2][k] ])
k=0
re = 'No'
for l in range(len(Bingo)):
  if len(list(set(num) & set(Bingo[l]))) == 3:
    re = 'Yes'
    break
print(re)
def p_d():
    from collections import Counter
    N = int(input())
    li = []
    for i in range(1, N + 1):
        li.extend(prime_factorize(i))
    prime_list = Counter(li).values()

    def num(m):
        return len(list(filter(lambda x: x >= m - 1, prime_list)))

    print(num(75) + num(25) * (num(3) - 1) + num(15) * (num(5) - 1) + num(5) * (num(5) - 1) * (num(3) - 2) // 2)


if __name__ == '__main__':
    p_d()


### FIXED CODE ###

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


def p_d():
    from collections import Counter
    N = int(input())
    li = []
    for i in range(1, N + 1):
        li.extend(prime_factorize(i))
    prime_list = Counter(li).values()

    def num(m):
        return len(list(filter(lambda x: x >= m - 1, prime_list)))

    print(num(75) + num(25) * (num(3) - 1) + num(15) * (num(5) - 1) + num(5) * (num(5) - 1) * (num(3) - 2) // 2)


if __name__ == '__main__':
    p_d()
import bisect
def put(a,b):
    a+="0"*20
    b+="0"*20
    s=""
    for  i in range(20):
        s+=a[i]+b[i]
    s=s[-1::-1]
    ind=s.find("1")
    if ind==-1:
        print(0)
    else:
        s=s[ind:]
        print(s[-1::-1])
 
def quad(i):
    s=""
    while i>0:
        s+=str(i%4)
        i//=4
    return s[-1::-1]
 
l=[0,1]
for i in range(1,22):
    l+=[4**i+j for j in l]
 
n=int(input())
for i in range(len(l)):
    if (n-l[i])%2==0:
        ind=bisect.bisect_left(l,(l[i]-n)//2)
        if l[i]-2*l[ind]==n:
            put(quad(l[i]),quad(l[ind]))
            break

### FIXED CODE ###

s=input().split()
n,m=int(s[0]),int(s[1])
s=input().split()
l=[0]
for i in range(n):
    l.append((l[-1]+int(s[i]))%m)
l.sort()
j=-1
cnt=-100
ll=[]
for i in range(len(l)):
    cnt+=1
    if j!=l[i]:
        j=l[i]
        ll.append(cnt)
        cnt=0
ll.append(cnt+1)
res=0
for i in ll:
    if i>1:
        res+=(i*(i-1))//2
print(res)
A = [int(input()) for _ in range(5)]
ans = 0
I = [i for i, a in enumerate(A) if a % 10 == 0]
for i in reversed(I):
    ans += A.pop(i)
A.sort(key=lambda a: a % 10)
ans += A.pop(0)
for i in range(len(A)):
    A[i] += 10 - (A[i] % 10)
ans += sum(A)
print(ans)


### FIXED CODE ###

from sys import stdin

num_dishes = 5
dishes = []
for i in range(5):
    dishes.append(int(stdin.readline()))
for i in range(0, num_dishes - 1):
    for j in range(i + 1, num_dishes):
        if (dishes[i] % 10 > dishes[j] % 10):
            dishes[i], dishes[j] = dishes[j], dishes[i]
dishes.sort(key=lambda d: d % 10)
got = False
ans = 0
for dish in dishes:
    if dish % 10 == 0:
        ans += dish
        continue
    else:
        if got:
            ans += dish + (10 - dish % 10)
        else:
            got = True
            ans += dish
print(ans)
a=input()
b=len(a)
print(a+a[len(b-1)]

### FIXED CODE ###

a=input()
b=input()
c=0
if (len(a)+1)!=len(b):
  print("No")
else:
  for i in range(len(a)):
    if a[i]==b[i]:
      c=c+1
  if c==len(a):
    print("Yes")
  else:
    print("No")
print("縦と横の長さを入力")

a=int(input())
b=int(input())

print(a*b)
print(a*2+b*2)



### FIXED CODE ###


a,b=map(int,input().split())

r=a*b
length=a*2+b*2
print(r,length)
AB = int(stdin.readline().rstrip().split())
x = max(AB)
y = max(x-1, min(AB))
print(x + y)


### FIXED CODE ###

a,b = map(int,input().split())
c = 0
d = 0
e = 0
c += max(a,b)
d += c
d -= 1
e += min(a,b)
c += max(d,e)
print(c)
import math

n = int(input())
a = list(map(int, input().split()))
x = a[0]
for i in range(1, n):
    x = math.gcd(x, a[i])
    if x == 1:
        break
print(x)

### FIXED CODE ###

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

n = int(input())
a = list(map(int, input().split()))
x = a[0]
for i in range(1, n):
    x = gcd(x, a[i])
print(x)
# union find, bfs

import sys
from collections import deque
si = sys.stdin.readline


def main():
    [n, m] = [int(e) for e in si().split()]
    if not m:
        print(1)
        return

    visited = [False]*(n+1)
    fm = [set() for _ in range(n+1)]
    mx, comp = 0, 0

    while m:
        m -= 1
        [a, b] = [int(e) for e in si().split()]
        fm[a].add(b)
        fm[b].add(a)

    for i in range(1, n+1):
        if visited[i]:
            continue
        visited[i] = True
        comp += 1
        q = deque()
        q.append(i)
        cnt = 1
        while q:
            curr = q.popleft()
            for e in fm[curr]:
                if not visited[e]:
                    visited[e] = True
                    q.append(e)
                    cnt += 1
        mx = max(mx, cnt)
    print(mx)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
si = sys.stdin.readline


def main():
    [d, t, s] = [int(e) for e in si().split()]
    if d <= t*s:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()
n,a,b=map(int, input().split())
s=input()
num=0
s_b=[i for i,x in s if x=='b']
for i in range(n):
  if s[i]=='c':
    print('No')
  elif s[i]=='a':
    if i <=(a+b):
      num+=1
      print('Yes')
    else:
      print('No')
  else:
    if s_b.index(i)<=b:
      num+=1
      print('Yes')
    else:
      print('No')   
  if num==a+b:
    break
    

### FIXED CODE ###

n,a,b=map(int, input().split())
s=list(input())
num=0
num_f=0
qual=[]
for i in range(n):
  if num<a+b:
    if s[i]=='a':
      num+=1
      qual.append('Yes')     
    elif s[i]=='b' and num_f<b:
      num+=1
      num_f+=1
      qual.append('Yes')
    else:
      qual.append('No')   
  else:
    qual.append('No')
for i in range(n):
  print(qual[i])
s, w = input().split()
if w >= s:
    print('unsafe'):
else:
    print('safe')
    

### FIXED CODE ###

s, w = [int(x) for x in input().split()]

if w >= s:
    print('unsafe')
else:
    print('safe')
a,b=input().split()
x= (a=="H")
y=(b=="H")
if x and y or not x and not y
  print("H")
else:
  print("D")

### FIXED CODE ###

a,b=input().split()
x= (a=="H")
y=(b=="H")
if x and y or not x and not y:
  print("H")
else:
  print("D")
import sys
import math

a,b,c,d = (int(i) for i in input().split())

c1 = b // c - (a - 1) // c
d1 = b // d - (a - 1) // d
cd = (c * d) //math.gcd(c,d)
cd1 = b // cd - (a - 1) // cd


print((b - a + 1) - c1 - d1 + cd1)

### FIXED CODE ###

import sys
import math
from fractions import gcd

a,b,c,d = (int(i) for i in input().split())

c1 = b // c - (a - 1) // c
d1 = b // d - (a - 1) // d
cd = (c * d) //gcd(c,d)
cd1 = b // cd - (a - 1) // cd



print((b - a + 1) - c1 - d1 + cd1)
mport collections
n = int(input())

d = collections.Counter(input())
for i in range(n - 1):
    words = collections.Counter(input())
    for w in words.keys():
        d[w] = min(words[w], d[w])
        
    for w in d.keys():
        d[w] = min(words[w], d[w])

ans = []
for char in d.keys():
    for i in range(d[char]):
        ans.append(char)

ans.sort()

print(''.join(ans))

### FIXED CODE ###

import collections
n = int(input())

d = collections.Counter(input())
for i in range(n - 1):
    words = collections.Counter(input())
    for w in words.keys():
        d[w] = min(words[w], d[w])
        
    for w in d.keys():
        d[w] = min(words[w], d[w])

ans = []
for char in d.keys():
    for i in range(d[char]):
        ans.append(char)

ans.sort()

print(''.join(ans))
import math
import copy

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

if N==2:
    print(max(A))
    exit()
else:
    max=0
    for i in range(N):
        x = copy.deepcopy(A)
        del x[i]
        c = math.gcd(x[0], x[1])
        for i in range(2,N-1):
            c = mat.gcd(c,x[i])
        if c >= max:
            max = c
    print(max)


### FIXED CODE ###

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

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

AL=[0]*N
AR=[0]*N
for i in range(N):
    if i == 0:
        AL[0] = A[0]
        AR[0] = A[N-1]
    else:
        AL[i] = gcd(AL[i-1],A[i])
        AR[i] = gcd(AR[i-1],A[N-i-1])

max=0
for i in range(N):
    if i == 0:
        n_ex_gcd =  AR[N-2]
    elif i == N-1:
        n_ex_gcd = AL[N-2]
    else:
        n_ex_gcd = gcd(AL[i-1],AR[N-i-2])
    if n_ex_gcd > max:
        max = n_ex_gcd
print(max)
l = int(input())
s = input()
s_dict = {}

for i in range(0, len(s)):
    if not s[i] in s_dict:
        s_dict[s[i]] = 1
    else:
        s_dict[s[i]] += 1

ans = 2**l
for v in s_dict.values():
    if not v == 1:
        ans *= ((2**v-1)/2**v)

ans -= 1
print(int(ans%(10**9+7)))


### FIXED CODE ###

l = int(input())
s = input()
s_dict = {}
l = len(s)
for i in range(l):
    if not s[i] in s_dict:
        s_dict[s[i]] = 1
    else:
        s_dict[s[i]] += 1
ans = 1
for v in s_dict.values():
    if v == 1:
    	ans *= 2
    else:
        ans *= v+1

print(int(ans-1)%(10**9+7))
modulo = 10 ** 9 + 7

N, K = map(int, input().split())
adj = {a: [] for a in range(1, N + 1)}
for i in range(N - 1):
    a, b = map(int, input().split())
    adj[a].append(b)
    adj[b].append(a)

def P(n, k):
    if n < k:
        return 0
    f = 1
    for i in range(n, n - k, -1):
        f = f * i % modulo
    return f

visited = set()

def ncoloring(root, d):
    """the number of coloring of a subtree at depth d
       when the color of the root has been decided."""
    visited.add(root)
    children = [s for s in adj[root] if s not in visited]
    remainingcolors = K - 2 if d > 0 else K - 1

    # coloring of the children
    p = P(remainingcolors, len(children)) % modulo

    # coloring of the subtrees
    for c in children:
        p = p * ncoloring(c, d + 1) % modulo
    return p

print(ncoloring(1, 0) * K % modulo)


### FIXED CODE ###

from collections import deque

modulo = 10 ** 9 + 7

N, K = map(int, input().split())
adj = {a: [] for a in range(1, N + 1)}
for i in range(N - 1):
    a, b = map(int, input().split())
    adj[a].append(b)
    adj[b].append(a)

def P(n, k):
    if n < k:
        return 0
    f = 1
    for i in range(n, n - k, -1):
        f = f * i % modulo
    return f

visited = set()
q = deque([1])
ncoloring = K  # num of coloring of the root

while len(q) > 0:
    u = q.popleft()
    visited.add(u)

    # coloring of the children
    children = [c for c in adj[u] if c not in visited]
    ncoloring *= P(K - 1 if u == 1 else K - 2, len(children))
    ncoloring %= modulo

    q.extend([c for c in children])

print(ncoloring)