Harryxun/stf_run huggingface dataset:
from bisect import bisect_left
import sys
sys.setrecursionlimit(1000000)


def dfs(v, p):
    i = bisect_left(dp, a[v])
    dp[i], old = a[v], dp[i]
    ans[v] = bisect_left(dp, INF)-1
    for u in to[v]:
        if u == p:
            continue
        dfs(u, v)
    dp[i] = old

if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))
    to = [[] for _ in range(n)]
    ans = [0]*n
    INF = 10**20
    for _ in range(n-1):
        u, v = map(int, input().split())
        u -= 1
        v -= 1
        to[u].append(v)
        to[v].append(u)
    if n == 2 and u == 1 and v == 0:
        print("yes")
        exit(0)
    dp = [INF]*n
    dp[0] = -INF
    dfs(0, -1)
    print("\n".join(list(map(str, ans))))

### FIXED CODE ###

from bisect import bisect_left
import sys
sys.setrecursionlimit(1000000)


def dfs(v, p):
    i = bisect_left(dp, a[v])
    dp[i], old = a[v], dp[i]
    ans[v] = bisect_left(dp, INF)-1
    for u in to[v]:
        if u == p:
            continue
        dfs(u, v)
    dp[i] = old

if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))
    to = [[] for _ in range(n)]
    ans = [0]*n
    INF = 10**20
    for _ in range(n-1):
        u, v = map(int, input().split())
        u -= 1
        v -= 1
        to[u].append(v)
        to[v].append(u)
    dp = [INF]*(n+1)
    dp[0] = -INF
    dfs(0, -1)
    print("\n".join(list(map(str, ans))))
a, b = map(int, input().split())
if (a + b) % 2 == 0:
  print((a + b) / 2)
else:
  print('IMPOSSIBLE')


### FIXED CODE ###

a, b = map(int, input().split())
if (a + b) % 2 == 0:
  print(int((a + b) / 2))
else:
  print('IMPOSSIBLE')
N = int(input())
I = list(map(int, input().split()))
minX = 10000000000
start = 0
for i in range(1, len(I)):
  start += I[i-1]
  minX = min(minX, abs(start - sum(I[-i:]) ) )
  
print(minX)

### 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")
def main():

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

    blue = ['b']*A
    red = ['r']*B
    l = []
    while len(l) <= N:
        l.extend(blue)
        l.extend(red)
    print(l[:N].count('b'))


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():

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

    # blue = ['b']*A
    # red = ['r']*B
    # l = []
    # while len(l) <= N:
    #     l.extend(blue)
    #     l.extend(red)
    # print(l[:N].count('b'))

    # c = 0
    # len = 0
    # while len <= N-A:
    #     len += A+B
    #     c += A
    # c += N-len
    # print(c)

    loops = N // (A+B)
    c = A*loops
    c += min(A, N % (A+B))
    print(c)


if __name__ == '__main__':
    main()
import re
s = input()
isHitachi = re.search("^(hi)+$")
if isHitachi:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

import re
s = input()
isHitachi = re.search("^(hi)+$", s)
if isHitachi:
  print("Yes")
else:
  print("No")
N, K = map(int, input().split())
S = input()

L = []
R = []
before = '1'
cnt_zero = 0
cnt_one = 0
len_l = 0
len_r = 0
for i in range(N):
    if before == '0' and S[i] == '0':
        cnt_zero += 1
    elif before == '0' and S[i] == '1':
        before = '1'
        L.append(cnt_zero)
        len_l += 1
        cnt_zero = 0
    elif before == '1' and S[i] == '0':
        before == '0'
        R.append(cnt_one)
        cnt_zero += 1
        cnt_one = 0
	else:
    	cnt_one += 1
      
if cnt_zero != 0:
    L.append(cnt_zero)
    len_l += 1

if cnt_one != 0:
	R.append(cnt_one)
	len_r = 0
ans = 0
sum_one = 0
if S[0] == '0'
	sum_one = sum(L[:K]) + sum(R[:K])
else:
	sum_one = sum(L[:K]) + sum(R[:K+1])

ans = sum_one

for i in range(len_l)[1:]:
  	if i + K > len_r:
		break
	if S[0] == '0' and i == 1:
		sum_one += (L[K] + R[K] - L[0])
    else:
		sum_one += (L[K+i-1] + R[K+i] - L[i-1] - R[i-1])
	ans = max(ans, sum_one)
print(ans)


### FIXED CODE ###

N, K = map(int, input().split())
S = input()

before = S[0]
cnt = 0
same_nums = []
if S[0] == '0':
  same_nums.append(0)
for i in range(N):
  if S[i] == before:
    cnt += 1
  else:
    same_nums.append(cnt)
    before = S[i]
    cnt = 1
same_nums.append(cnt)
if S[-1] == '0':
  same_nums.append(0)
  
sum_nums = sum(same_nums[:2*K+1])
ans = sum_nums
for i in range(0, len(same_nums)-2*K, 2):
  sum_nums = sum_nums - sum(same_nums[i:i+2]) + sum(same_nums[i+2*K+1:i+2*K+3])
  ans = max(ans, sum_nums)
print(ans)
# coding: utf-8
# Your code here!

inp = input().split()
N = int(inp[0])
K = int(inp[1])

S = input()

ch:str = S[K - 1]


print(S[:K - 1] + ch.lower() + S[K:])



### FIXED CODE ###

# coding: utf-8
# Your code here!

inp = input().split()
N = int(inp[0])
K = int(inp[1])

S = input()

ch = S[K - 1]

print(S[:K - 1] + ch.lower() + S[K:])
from sys import stdin

n = int(stdin.readline().rstrip())
ans = 0

from numba import njit

@njit
def solve(n):
    for i in range(n):
        ans += i
    return ans

print(solve(n))

### FIXED CODE ###

from sys import stdin

n = int(stdin.readline().rstrip())
ans = 0
ans = (n-1) * (n) // 2

print(ans)
A = int(input())
B = int(input())
Ans = (A-1)*(B-1)
print(Ans)

### FIXED CODE ###

a,b = map(int,input().split())
ans = (a-1)*(b-1)
print(ans)
def main():
    N, M = [int(x) for x in input().split()]
    d = dict()
    for _ in range(M):
        s, c = [int(x) for x in input().split()]
        if s in d and d[s] != c or (N!=1 and s==1 and c==0):
            print(-1)
            return
        d[s] = c
    nums = [0] * N
    for s, c in d.items():
        nums[s-1] = c
    for i in range(min(d.keys())-1):
        nums[i] = 1
        break
    ans = "".join(map(str, nums))
    print(ans)


if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    N, M = [int(x) for x in input().split()]
    d = dict()
    for _ in range(M):
        s, c = [int(x) for x in input().split()]
        s -= 1
        if s in d and d[s] != c:
            print(-1)
            return
        d[s] = c

    def is_ok(n) -> bool:
        t = str(n)
        if len(t) != N:
            return False
        for s, c in d.items():
            if t[s] != str(c):
                return False
        return True

    for i in range(10**N):
        if is_ok(i):
            print(i)
            return
    print(-1)


if __name__ == '__main__':
    main()
a,b=map(int,input().split())

ans=[]

if b==1:
  print('0')

else:
  for i in range(20):
    if b<=a+(a-1)*i:
      ans.append(i+1)

print(min(ans))

### FIXED CODE ###

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

ans=[]

if b==1:
  print('0')

else:
  for i in range(20):
    if b<=a+(a-1)*i:
      ans.append(i+1)
  print(min(ans))
from collections import Counter

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

ki = v[::2]
gu = v[1::2]

ki = Counter(ki)
gu = Counter(gu)

ki = ki.most_common()
gu = gu.most_common()

ans = 0

if ki[0][0] == gu[0][0]:
    if len(ki) == 1 and len(gu) == 1:
        ans = int(n / 2)
    else:
        if ki[0][1] > gu[0][1]:
            ans = n - ki[0][1]
        else:
            ans = n - gu[0][1]
else:
    ans = n - ki[0][1] - gu[0][1]

print(ans)


### FIXED CODE ###

n = [x for x in str(input())]
add_stock = ''

for i in n:
    add = i
    if i == '1':
        add = '9'
    elif i == '9':
        add = '1'
    add_stock += add

print(add_stock)
import sys
input = sys.stdin.readline

n,Q=map(int,input().split())
bn = 17
b_num = 131072
mx = 10**9
segl=[mx]*2*b_num 

#xs = [[int(c) for c in input().split()] for _ in range(n)]
xs = []
for i in range(n):
    s,t,x=[int(c) for c in input().split()]
    xs += [(s-x,0,x,i), (t-x,1,x,i)]
for _ in range(Q):
    xs.append((int(input()),2,0,0))
xs.sort()
ys = set()
for x in xs:
    if x[1]==2:
        for _ in range(bn):
            nys = set()
            ys = nys
        print(segl[0] if segl[0]!= mx else -1)
        ys = set()
        continue
    segl[x[3]+b_num-1] = mx if x[1] else x[2]
    ys.add((x[3]+b_num-2)//2)


### FIXED CODE ###

import sys
input = sys.stdin.readline

n,Q=map(int,input().split())
b_num = 2**(n-1).bit_length()
mx = 10**9
segl=[mx]*2*b_num 

def update( k, x):
    k += b_num-1
    segl[k] = x
    while k+1:
        k = (k-1)//2
        segl[k] = min(segl[k*2+1],segl[k*2+2])
    
if __name__ == '__main__':
    xs = []
    for i in range(n):
        s,t,x=map(int,input().split())
        xs += [(s-x-0.4,True,x,i), (t-x-0.5,False,x,i)]
    for _ in range(Q):
        xs.append((int(input()),2))
    xs.sort(key=lambda x:x[0])
    for x in xs:
        if x[1]==2:
            print(segl[0] if segl[0]!= mx else -1)
            continue
        update(x[3], x[2] if x[1] else mx)
w = input()

for i in w:
    if w.count(i)%2! = 0:
        print("No")
        break
    else:
        print("Yes")



### FIXED CODE ###

w = input()

ans = "No"
for i in w:
    if w.count(i)%2!= 0:
        break
else:
    ans = "Yes"
print(ans)
n = int(input())
print(round(format((n)*(n-1)/2,"f")))

### FIXED CODE ###

from collections import defaultdict
import bisect

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()


n = readInt()
print(n*(n-1)//2)
S,T= map(strinput().split())
A=len(S)
B=len(T)
ptint(A,{},B)
U =input()
if U==S:
  A-=S
elif U==T:
  B-=1
else:
  pass

### FIXED CODE ###

S,T= map(str,input().split())
A,B=map(int,input().split())
U =input()
if U==S:
  A-=1
elif U==T:
  B-=1
else:
  pass
print(A,B)
N = int(input())
A = list(map(int, input().split()))

c = [0, 0, 0]

sum = 1
# print(c)
for a in A:
    # print(a)
    if a == c[0]:
        c[0] += 1
        tmp = c.count(c[0] - 1) + 1
    elif a == c[1]:
        c[1] += 1
        tmp = c.count(c[1]-1) + 1
    elif a == c[2]:
        c[2] += 1
        tmp = c.count(c[2] - 1) + 1
    # print(tmp)
    sum = sum * tmp % 1000000007
    # print(c)
print(sum)


### FIXED CODE ###

N = int(input())
A = map(int, input().split())
MOD = 1000000007
ans = 1
cnt = [3 if i == 0 else 0 for i in range(N + 1)]
 
for a in A:
    ans = ans * cnt[a] % MOD
    if ans == 0:
        break
    cnt[a] -= 1
    cnt[a+1] += 1
 
print(ans)
a, b = map(int,input().split())

if a<b:
    a,b=b,a

if a%b == 0:
    print(0)
else:
    c=a//b
    d=a%b
    a=a-b*c
    while abs(a-b)<a:
        a=abs(a-b)
    print(a)

### FIXED CODE ###

n,k=map(int,input().split())
print(min(n%k,abs(n%k-k)))
a = int(input())
s = int(input())
print(s if a < 3200 else "red")


### FIXED CODE ###

a = int(input())
s = input()
print(s if a >= 3200 else "red")
a,b,c=map(int,input());print(min(b//a,c))

### FIXED CODE ###

a,b,c=map(int,input().split());print(min(b//a,c))
ai = lambda: list(map(int,input().split()))
n, z, w = ai()
a = ai()
if n == a:
    print(abs(a[-1]-w))
else:
    print(max(abs(a[-1]-w), abs(a[-1]-a[-2])))


### FIXED CODE ###

ai = lambda: list(map(int,input().split()))
n, z, w = ai()
a = ai()
if n == 1:
    print(abs(a[-1]-w))
else:
    print(max(abs(a[-1]-w), abs(a[-1]-a[-2])))
import fractions
def lcm(a, b):
    return a * b / fractions.gcd(a, b)

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

A_half = [0.5 * a for a in A]
A_lcm = A_half[0]

for i in range(1, N):
    A_lcm = lcm(int(A_lcm), int(A_half[i]))

for i in A_half:
    if A_lcm // i % 2 == 0:
        print(0)
        exit()
ans = (M // A_lcm + 1) // 2
print(int(ans))

### FIXED CODE ###

from fractions import gcd

N, M = map(int, input().split())
A = [int(i) // 2 for i in input().split()]  

A_lcm = 1
for i in range(N):
    A_lcm *= A[i] // gcd(A_lcm, A[i])
    
for i in A:
    if A_lcm // i % 2 == 0:
        print(0)
        exit()

print((M // A_lcm + 1) // 2)
A = int(input())
B = int(input())

X =A*B
print(X)

### FIXED CODE ###

A,B = map(int,input().split())
print(A * B)
import numpy as np
N = int(input())
B = str(input())

B_array = np.array(list(map(int, list(B))))
B_1 = B_array.sum()
mod_list_m1 = []
mod_list = []
mod_list_p1 = []
for i in range(N):
    mod_list.append((2**i) % (B_1))
    mod_list_m1.append((2**i) % (B_1-1))
    mod_list_p1.append((2**i) % (B_1+1))
mod_list = np.array(mod_list)[::-1]
mod_list_m1 = np.array(mod_list_m1)[::-1]
mod_list_p1 = np.array(mod_list_p1)[::-1]

mod_m1 = B_array.dot(mod_list_m1) % (B_1-1)
mod_p1 = B_array.dot(mod_list_p1) % (B_1+1)

def calc_small(n, iter):
    iter += 1
    mod = n % bin(n).count("1")
    if mod == 0:
        return iter
    else:
        return calc_small(mod, iter)

for i in range(N):
    mod = (mod_m1 - mod_list_m1[i]) % (B_1-1) if B_array[i] == 1 else (mod_p1 + mod_list_p1[i]) % (B_1+1)
    iter = 1
    if mod == 0:
        print(iter)
    else:
        print(calc_small(mod, iter))


### FIXED CODE ###

N = int(input())
B = input()

B_1 = B.count("1")
mod_p1 = int(B,2) % (B_1+1)
if B_1 != 1:
    mod_m1 = int(B,2) % (B_1-1)

def calc_small(n, iter):
    iter += 1
    mod = n % bin(n).count("1")

    if mod == 0:
        return iter
    else:
        return calc_small(mod, iter)

for i in range(N):
    if B_1 == 1 and int(B[i]) == 1:
        print(0)
        continue
    mod = (mod_m1 - pow(2,N-i-1,B_1-1)) % (B_1-1) if int(B[i]) == 1 else (mod_p1 + pow(2,N-i-1,B_1+1)) % (B_1+1)
    iter = 1
    if mod == 0:
        print(iter)
    else:
        print(calc_small(mod, iter))
n, q = map(int, input().split())
s = input()
for i in range(q):
    list_q = list(map(int, input().split()))
    list_q[0] = list_q[0] - 1
    list_q[1] = n - list_q[1]
    min_num = min(list_q)
    for j in range(min_num):
        s = s[1:]
        s = s[:-1]
    for k in range(list_q[0] - min_num):
        s = s[1:]
    for k in range(list_q[1] - min_num):
        s = s[:-1]
    s = s.split("AC")
    print(len(s) - 1)


### FIXED CODE ###

import sys
input = sys.stdin.readline
N, Q = map(int,input().split())
S = list(input())[:-1]
list_Sum = [0]*(N+1)
for i in range(1, N):
    list_Sum[i+1] = list_Sum[i]
    if S[i-1] == "A" and S[i] == "C":
        list_Sum[i+1] += 1
for i in range(Q):
    l, r = map(int,input().split())
    print(list_Sum[r]-list_Sum[l])
a, b = map(int, input().split())
if b != 0:
    c = input()
    l = c.split()
    cc = [int(s) for s in l]
    ccc =list(cc)
    for i in range(a,100):
        if i in ccc:
            continue
        else:
            x = i
            break
    for i in reversed(range(-100, a)):
        if i in ccc:
            continue
        else:
            y = i
            break
    if x-a<a-y:
        print(x)
    else:
        print(y)
else:
    d = input()
    print(a)

### FIXED CODE ###

a, b = map(int, input().split())
if b != 0:
    c = input()
    l = c.split()
    cc = [int(s) for s in l]
    ccc =list(cc)
    for i in range(a,102):
        if i in ccc:
            continue
        else:
            x = i
            break
    for i in reversed(range(0, a)):
        if i in ccc:
            continue
        else:
            y = i
            break
    if x-a<a-y:
        print(x)
    else:
        print(y)
else:
    d = input()
    print(a)
n, m=input().split()
print((n-1)*(m-1))

### FIXED CODE ###

n, m=input().split()
print((int(n)-1)*(int(m)-1))
import math

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

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

print(lcm(A, B))

### FIXED CODE ###

from fractions import gcd

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

def lcm(x, y):
    return (x * y) // gcd(x, y)

print(lcm(A, B))
a,b,k=map(int,input().split())
arr=list(range(a,b+1))
for i in range(b-a+1):
  if i < k or i >= len(arr) - k:
    print(arr[i])

### FIXED CODE ###

a,b,k=map(int,input().split())
if 2*k >= b-a+1:
  print(*list(range(a,b+1)),sep='\n')
else:
  print(*list(range(a,a+k)),sep='\n')
  print(*list(range(b-k+1,b+1)),sep='\n')
from collections import Counter
N = int(input())
xy = [tuple(map(int,input().split())) for i in range(N)]
ct = Counter()
for i in range(N):
  for j in range(i+1,N):
    dx = xy[i][0]-xy[j][0]
    dy = xy[i][1]-xy[j][1]
    ct[(dx,dy)] += 1
print(N-max(ct.values()))

### FIXED CODE ###

from collections import Counter
N = int(input())
xy = [tuple(map(int,input().split())) for i in range(N)]
ct = Counter()
for i in range(N):
  for j in range(i+1,N):
    dx = xy[i][0]-xy[j][0]
    dy = xy[i][1]-xy[j][1]
    ct[(dx,dy)] += 1
    ct[(-dx,-dy)] += 1
print(N-max(ct.values() if len(ct)>0 else [0]))
from scipy.special import comb
# a = comb(n, r)
#a = comb(n, r, exact=True)

N,K= map(int,input().split())
mod = 10**9+7
#def comb(n, k):
#    m = 1
#    if n< k:
#        m= 0
#    if n < 2 * k:
#        k = n - k
#    for i in range(1, k + 1):
#        m = m * (n - i + 1) / i  %mod  
#    return int(m)
#print(comb(1,2))
R = N-K


for i in range(1,K+1):
    # blue
#    if i == 1:
#        b_div = 2
#    else:
#    print(R,i)
    b_div = comb(K-1,i-1)%mod
    # RED
#    if (R+1)<i:
#        print('0')
#    else:
    r_div = comb(R+1,i)%mod
#        if i == K+1:
#            r_div += comb(R+1,i+1)%mod
        
#        print(b_div,r_div)
    print(int(b_div*r_div)%mod)

### FIXED CODE ###




N,K= map(int,input().split())
mod = 10**9+7
def comb(n,k):
  """power_funcを用いて(nCk) mod p を求める"""
  p = 10**9+7
  from math import factorial
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=factorial(n) %p
  b=factorial(k) %p
  c=factorial(n-k) %p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p
R = N-K


for i in range(1,K+1):
    # blue
#    if i == 1:
#        b_div = 2
#    else:
#    print(R,i)
    b_div = comb(K-1,i-1)%mod
    # RED
#    if (R+1)<i:
#        print('0')
#    else:
    r_div = comb(R+1,i)%mod
#        if i == K+1:
#            r_div += comb(R+1,i+1)%mod
        
#        print(b_div,r_div)
    print(int(b_div*r_div)%mod)
import collections
n=int(input())
l=[[] for i in range(n)]
ans=[0]*(n-1)

def dfs(v,c,p):
  k=1
  for i in range(len(l[v])):
    u=l[v][i][0]
    id=l[v][i][1]
    if(u==p):continue
    if(k==c):k+=1
    ans[id]=k
    k+=1
    dfs(u,ans[id],v)
for i in range(n-1):
  a,b=map(int,input().split())
  l[a-1].append((b-1,i))
  l[b-1].append((a-1,i))
dfs(0,-1,-1)
print(max(ans))
for i in ans:
  print(i)

### FIXED CODE ###

import sys
sys.setrecursionlimit(500000)

n=int(input())
l=[[] for i in range(n)]
ans=[0]*(n-1)

def dfs(v,c,p):
  k=1
  for i in range(len(l[v])):
    u=l[v][i][0]
    id=l[v][i][1]
    if(u==p):continue
    if(k==c):k+=1
    ans[id]=k
    dfs(u,ans[id],v)
    k+=1
for i in range(n-1):
  a,b=map(int,input().split())
  l[a-1].append((b-1,i))
  l[b-1].append((a-1,i))
dfs(0,-1,-1)
print(max(ans))
for i in ans:
  print(i)
""" AtCoder """

N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

check = True

for i in range(N - M + 1):
    check = True
    for j in range(M):
        count = 0
        for jj in range(N - M + 1):
            if A[i + jj][j:j + M] != B[jj]:
                check = False
                break
            count += 1
        if count == M:
            print("Yes")
            exit()
        if not check:
            break

print("No")


### FIXED CODE ###

""" AtCoder """

N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

for i in range(N - M + 1):
    for j in range(N - M + 1):
        count = 0
        for jj in range(M):
            if A[i + jj][j:j + M] != B[jj]:
                break
            count += 1
        if count == M:
            print("Yes")
            exit()

print("No")
a = int(input())
if a < 1200 :
    prunt('ABC')
elif a >= 1200 and a < 2800 :
    print('ARC')
else :
    print('AGC')

### FIXED CODE ###

a = int(input())
if a < 1200 :
    print('ABC')
elif a >= 1200 and a < 2800 :
    print('ARC')
else :
    print('AGC')
n = int(input())
s = input()

arr = []

for i in range(n-1):
    if s[i+1] != s[i]:
        arr.append(s[i+1])
        

if s[-1] != s[-2]:
    arr.append(s[-1])

c = len("".join(arr))

if c == 0:
    print(1)
else:
    print(c)

### FIXED CODE ###

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

arr = []
arr.append(s[0])
for i in range(n-1):
    if s[i+1] != s[i]:
        arr.append(s[i+1])


c = len(arr)
print(c)
s=list(map(int,input().split()))

for i in range(10):
  if s[i]==h and a[i+1]==i:
    print('Yes')
    exit()
    
print('No')    
    

### FIXED CODE ###

s=str(input())
a=len(s)
b=['hi','hihi','hihihi','hihihihi','hihihihihi']
if a%2!=0:
  print('No')
elif s in b:
  print('Yes')
else:
  print('No')
M=10**9+7;n,k,*A=map(int,open(0).read().split());C=[[0]*(n+1)for _ in"_"*(n+1)]
for i in range(n+1):
 for j in range(n):C[i][j]=(1,C[i-1][j-1]+C[i-1][j])[j>0]%M
F=[[0]*(n+1)for _ in"_"*n];F[0][0]=1
for i in range(k):
 for j in range(n+1):
  for m in range(j+1):F[i+1][j]+=C[j][m]*F[i][m]*C[n-j+m][A[i]-j+m]
print(F[k][n]%M)

### FIXED CODE ###

import sys
input = sys.stdin.readline
U = 1000
MOD = 10**9+7
 
fact = [1]*(U+1)
fact_inv = [1]*(U+1)
 
for i in range(1,U+1):
    fact[i] = (fact[i-1]*i)%MOD
fact_inv[U] = pow(fact[U], MOD-2, MOD)
 
for i in range(U,0,-1):
    fact_inv[i-1] = (fact_inv[i]*i)%MOD

def comb(n, k):
    if k < 0 or k > n:
        return 0
    z = fact[n]
    z *= fact_inv[k]
    z %= MOD
    z *= fact_inv[n-k]
    z %= MOD
    return z

n, k = map(int, input().split())
A = list(map(int, input().split()))
F = [[0]*(n+1) for _ in range(k+1)]
F[0][0] = 1
for i in range(k):
  for j in range(n+1):
    for m in range(j+1):
      F[i+1][j] += comb(j, m) * F[i][m] * comb(n-(j-m), A[i]-(j-m))
    F[i+1][j] %= MOD
ans = F[k][n]
print(ans)
n = int(input())
a = list(map(int, input().split()))
a_set = set(a)
sides = []

for i in a_set:
    if a.count(i) > 1:
        sides.append(i)

if len(sides) <= 1:
    print(0)

sides = sorted(sides)
print(sides[-1]*sides[-2])

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
s = set()
cands = []

for i in a:
    if i in s:
        cands.append(i)
        s.remove(i)
    else:
        s.add(i)

x = sorted(cands, reverse=True)
if len(x) < 2:
    print(0)
else:
    print(x[0]*x[1])
N = int(input())
S = int(input())

def f(b,n):
    if n//b==0:
        return n
    else:
        return n%b + f(b,n//b)

ans = -1
if S==N:
    ans = N+1
else:
    for b in range(2,int(N**.5)+1):
        if f(b,N)==S:
            ans = b
            break
    for i in range(int(N**.5)+1,0,-1):
        b = (N-S)//i + 1
        if b>0:
            if f(b,N)==S:
                ans = b
                break

print(ans)

### FIXED CODE ###

N = int(input())
S = int(input())

def f(b,n):
    if n//b==0:
        return n
    else:
        return n%b + f(b,n//b)

ans = -1
if S==N:
    ans = N+1
else:
    for b in range(2,int(N**.5)+1):
        if f(b,N)==S:
            ans = b
            break

if ans == -1:
    for i in range(int(N**.5)+1,0,-1):
        b = (N-S)//i + 1
        if b>1:
            if f(b,N)==S:
                ans = b
                break

print(ans)
D,T,S=map(int,input().split())
if D<S*T
 print(Yes)
else
 print(No)

### FIXED CODE ###

D,T,S=map(int,input().split())
if T*S>=D:
  print("Yes")
else:
  print("No")
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
#from scipy.misc import comb

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

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

print(ans)

### FIXED CODE ###

#coding: utf-8
import math
import heapq
import bisect
import numpy as np
import fractions
#from scipy.misc import comb

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

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

print(ans)
a = input()
a[3] = '8'
print(a)

### FIXED CODE ###

a = input()
a = a.replace('2017','2018')
print(a)
n, m = map(int, input().split())
l = 1
r = 10 ** 5
for _ in range(m):
    li, ri = map(int, input().split())
    l = max(l, li)
    r = min(r, ri)

print(r - l + 1 if r >= l else 0)


### FIXED CODE ###

n = int(input())
ans = 0
score = []
for _ in range(n):
    score.append(int(input()))

score.sort()
total = sum(score)
if total % 10 == 0:
    for s in score:
        if s % 10 != 0:
            total -= s
            break

print(total if total % 10 != 0 else 0)
a,b,c=map(int,input().split())
if(a%2==0 and b%2==0 and c%2==0):
  print('Yes')
else:
  print('No')

### FIXED CODE ###

a,b=map(int,input().split())
if a%2==0 or b%2==0:
  print('No')
else:
  print('Yes')