Harryxun/stf_run huggingface dataset:
S = input()
w = int(input())
s = ''
if w == 1:
  print(S)
else:
  for i in range((len(S) // w) + 1):
    s += S[i * w]
print(s)


### FIXED CODE ###

S = input()
w = int(input())
s = ''
if w == 1:
  print(S)
else:
  if len(S) % w == 0:
    for i in range(len(S) // w):
      s += S[i * w]
    print(s)
  else:
    for i in range((len(S) // w) + 1):
      s += S[i * w]
    print(s)
, M = map(int, input().split())
A = list(map(int, input().split()))

cnt = 0
th = sum(A)/(4*M)

for i in range(len(A)):
  if A[i] >= th:
    cnt += 1

ans = 'Yes' if cnt >= M else 'No'
print(ans)

### FIXED CODE ###

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

cnt = 0
th = sum(A)/(4*M)

for i in range(len(A)):
  if A[i] >= th:
    cnt += 1

ans = 'Yes' if cnt >= M else 'No'
print(ans)
#!/usr/bin/env python3
# coding: utf-8

# def debug(arg):
#     if __debug__:
#         pass
#     else:
#         import sys
#         print(arg, file=sys.stderr)
        
def main():
    N, K, C = map(int, input().split())
    S = dict(enumerate(str(input()), 1))

    sr = list(k for k, v in S.items() if v == 'o')
    sl = list(reversed(sr.copy()))

    l = [sl.pop()]
    r = [sr.pop()]
    
    for x in range(1, K):
        while True:
            y = sl.pop()
            if y > l[x - 1] + 3:
                l.append(y)
                break
        while True:
            y = sr.pop()
            if y < r[x - 1] - 3:
                r.append(y)
                break

    a = (set(l) & set(r))
    for aa in a:
        print(aa)

if __name__ == "__main__":
    main()

### FIXED CODE ###

#!/usr/bin/env python3
# coding: utf-8

def debug(arg):
    if __debug__:
        pass
    else:
        import sys
        print(arg, file=sys.stderr)
        
def main():
    N, K, C = map(int, input().split())
    S = dict(enumerate(str(input()), 1))

    sr = list(k for k, v in S.items() if v == 'o')
    sl = list(reversed(sr.copy()))

    debug(sr)
    debug(sl)

    l = [sl.pop()]
    r = [sr.pop()]
    
    for x in range(1, K):
        while True:
            ll = sl.pop()
            if ll > l[x - 1] + C:
                l.append(ll)
                break
        while True:
            rr = sr.pop()
            if rr < r[x - 1] - C:
                r.append(rr)
                break

    debug(r)
    debug(l)

    # a = sorted(set(l) & set(r))

    # debug(a)
    # for aa in a:
    #     print(aa)
    
    for ll, rr in zip(l, sorted(r)):
        if ll == rr:
            print(ll)

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

sys.setrecursionlimit(10**9)


H,W,D=map(int,input().split())

dic={}
A=[]
for h in range(H):
    A.append(list(map(int,input().split())))
    for w in range(W):
        dic[A[h][w]]=[h,w]

Q=int(input())

c=[-1]*(H*W+1)
def rec(n):
    if c[n]!=-1:
        return [c[n]]
    y,x=dic[n]
    ny,nx=dic[n+D]
    ret=abs(y-ny)+abs(x-nx)
    c[n]=ret
    return ret

for i in range(Q):
    L,R=map(int,input().split())
    N=(R-L)//D
    ans=0
    for j in range(N):
        ans+=rec(L+D*j)
    print(ans)

### FIXED CODE ###

H,W,D=map(int,input().split())
A=[]

for h in range(H):
    A.append(list(map(int,input().split())))

pos= {}
for h in range(H):
    for w in range(W):
        pos[A[h][w]]=[h,w]

S=[0]*(H*W)
for d in range(D):
    tmp=0
    now=d+1
    while now+D<=H*W:
        nowh,noww=pos[now]
        newh,neww=pos[now+D]
        tmp+=abs(nowh-newh)+abs(noww-neww)
        S[now+D-1]=tmp
        now+=D

Q=int(input())
for i in range(Q):
    L,R=map(int,input().split())
    ans=S[R-1]-S[L-1]
    print(ans)
N = int(input())
A = list(map(int, input().split()))
MOD = 10**9+7

ans = 1
dp = [0]*3
for a in A:
    ans = ans*dp.count(a) % MOD
    dp[dp.index(a)] += 1
print(ans)


### FIXED CODE ###

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

ans = 1
dp = [0]*3
for a in A:
    cnt = 0
    for i in range(3):
        if a == dp[i]:
            cnt += 1
    for i in range(3):
        if a == dp[i]:
            dp[i] += 1
            break
    ans = ans*cnt % MOD
print(ans)
A, B ,K = list(map(int, input(),split()))
for k in range(K):
  if A>0:
    A -= 1
  elif A=0 and B>0:
    B -= 1
  else:
    break
else:
  print(A B)

### FIXED CODE ###

A, B ,K = list(map(int, input().split()))
if A > K:
  print(A-K, B)
else:
  b = B-(K-A) if B>(K-A) else "0"
  print(0, b)
sfhgfh

### FIXED CODE ###

n,m = map(int,input().split())
 
a = [ int(x) for x in input().split()]
limit = sum(a)/(4*m)
 
count=0
for x in a:
  	if(x>=limit):
      			count+=1
if(count<m):
  	print('No')
else:
  	print('Yes')
vn,m,q=map(int,input().split())
lis=[]
for i in range(q):
    a,b,c,d=map(int,input().split())
    lis.append((a,b,c,d))
    
from itertools import combinations_with_replacement

co=list(combinations_with_replacement(range(1,m+1),n))

ans=0
for status in co:
    tmp_score=0
    for a,b,c,d in lis:
        if status[b-1]-status[a-1]==c:
            tmp_score+=d
    ans=max(ans,tmp_score)
print(ans)


### FIXED CODE ###

n,m,q=map(int,input().split())
lis=[]
for i in range(q):
    a,b,c,d=map(int,input().split())
    lis.append((a,b,c,d))
    
from itertools import combinations_with_replacement

co=list(combinations_with_replacement(range(1,m+1),n))

ans=0
for status in co:
    tmp_score=0
    for a,b,c,d in lis:
        if status[b-1]-status[a-1]==c:
            tmp_score+=d
    ans=max(ans,tmp_score)
print(ans)
list=[1, 1, 1, 1, 1]
for i in range(1, 7):
  list.append(6**i)
for j in range(1, 7):
  list.append(9**i)
sort(list, reverse=True)

### FIXED CODE ###

N=int(input())

A=[1]

i = 1
while True:
    if 6**i <= 100000:
        A.append(6**i)
    else:
        break
    i += 1

i = 1
while True:
    if 9**i <= 100000:
        A.append(9**i)
    else:
        break
    i += 1

A.sort()

dp = [N]*(N+1)
dp[0] = 0
for i in range(1, N+1):
    for j in range(len(A)):
        if i - A[j] >= 0:
            dp[i] = min(1+dp[i-A[j]], dp[i])

print(dp[-1])
i = 1
while True:
    x = int(input().strip())
    if x == 0:
        break
    else:
        print ("Case {}: {}").format(i,x)
        i += 1

### FIXED CODE ###

i = 1
while True:
    x = int(input().strip())
    if x == 0:
        break
    else:
        print ("Case {}: {}".format(i,x))
        i += 1
D,N = list(map(int, input().split()))
print(n * (100 ** D))

### FIXED CODE ###

d, n = list(map(int, input().split()))
cnt = 0
i = 1

while True:
  if(d == 0 and i % 100 != 0):
    cnt += 1    
  if(d != 0 and i % (100 ** d) == 0 and i % (100 ** (d+1)) != 0):
    cnt += 1
  if(cnt == n):
    print(i)
    exit()
  i += 1
import sys
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value

from collections import deque
N, M = mi()
x = li2(M)

h = [0]*N
adj = [[] for i in range(N)]
for i in range(M):
    x[i][0] -= 1
    x[i][1] -= 1
    h[x[i][1]] += 1
    adj[x[i][0]].append(x[i][1])

flag = [0]*N
ans = deque([])

def dfs(x):
    if flag[x]:
        return False
    else:
        flag[x] = 1
        for a in adj[x]:
            dfs(a)
        global ans
        ans.appendleft(x)

for i in range(N):
    dfs(i)

#print(ans)

dp = [0]*N
for a in ans:
    for b in adj[a]:
        dp[b] = max(dp[b], dp[a] + 1)

print(max(dp))

### FIXED CODE ###

import sys
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
'''
N, M = mi()
x = li2(M)

#dp = dp2(0, 2, N)
dp = [[0, []] for i1 in range(N+1)]


for i in range(M):
    dp[x[i][1]][0] = max(dp[x[i][1]][0], dp[x[i][0]][0] + 1)
    dp[x[i][0]][1].append(x[i][1])
    if dp[x[i][1]][1] != []:
        for a in dp[x[i][1]][1]:
            dp[a][0] = max(dp[x[i][1]][0] + 1, dp[a][0])

print(dp)
print(max([row[0] for row in dp])) 
'''
from collections import deque
N, M = mi()
x = li2(M)

h = [0]*N
adj = [[] for i in range(N)]
for i in range(M):
    x[i][0] -= 1
    x[i][1] -= 1
    h[x[i][1]] += 1
    adj[x[i][0]].append(x[i][1])

zeros = deque([])
ans = []
for i in range(N):
    if h[i] == 0:
        zeros.append(i)
        ans.append(i)

while(zeros != deque()):
    a = zeros.popleft()
    if(adj[a]):
        for b in adj[a]:
            h[b] -= 1
            if h[b] == 0:
                zeros.append(b)
                ans.append(b)

#print(ans)

dp = [0]*N
#print(ans)
#print(adj)
for a in ans:
    #print(dp)
    if adj[a]:
        for b in adj[a]:
            dp[b] = max(dp[a] + 1, dp[b])
#print(dp)
print(dp[ans[-1]])
import math

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

x = 360//12
y = 360//60

a = M*y
b = (H+ M/60)*x

if a>=b:
  if a-b>180:
    k = 360 - a+b
  elif a - b == 180:
    print(A+B)
  else:
    k = a-b
else:
  if b-a>180:
    k = 360 - b+a
  elif b-a == 180:
    print(A+B)
  else:
    k = b-a
    
k = math.radians(k)

ans = A*A + B*B - 2*A*B*math.cos(k)

print(math.sqrt(ans))

### FIXED CODE ###

import math

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

x = 360//12
y = 360//60

a = M*y
b = (H+M/60)*x
T = 1
if a>=b:
  if a-b>180:
    k = 360 - a+b
  elif a - b == 180:
    print(A+B)
    T = 0
  else:
    k = a-b
else:
  if b-a>180:
    k = 360 - b+a
  elif b-a == 180:
    print(A+B)
    T = 0
  else:
    k = b-a

if T == 1:
  k = math.radians(k)

  ans = A*A + B*B - 2*A*B*math.cos(k)

  print(math.sqrt(ans))
N = int(input())
for i in range(1,n):
    ans += (n-1) // i
print(ans)

### FIXED CODE ###

N = int(input())
ans = 0
for i in range(1,N):
    ans += (N - 1) // i
print(ans)
a, b = raw_input().split()
Z = [a * b, b * a]
print sorted(Z)[0]

### FIXED CODE ###

a, b = raw_input().split()
Z = [a * int(b), b * int(a)]
print sorted(Z)[0]
X=int(input())

DP=[False]*(X+1)

for i in range(100,106):
    DP[i]=True

for i in range(106,X+1):
    if DP[i-100] or DP[i-101] or DP[i-102] or DP[i-103] or DP[i-104] or DP[i-105]:
        DP[i]=True

if DP[X]==True:
    print(1)
elif DP[X]==False:
    print(0)


### FIXED CODE ###

X=int(input())

t=X//100

if 100*t<=X<=105*t:
    print(1)
else:
    print(0)
O = input()
E = input()
str = ""
i = 0
while True:
  str = str + O[i]
  if len(E)-1<i:
    exit(1)
  str = str + E[i]
  i+=1
  
print(str)

### FIXED CODE ###

O = input()
E = input()
str = ""
i = 0
while True:
  str += O[i]
  str += E[i]
  i+=1
  if len(E)-1<i:break
if len(O)-len(E)==1:
  str+=O[-1]
print(str)
def main():
    n, m = map(int, input().split())
    wxyz = [list(map(int, input().split())) for _ in [0]*m]

    class unionfind():
        # size:要素数,tree：unionfind木
        def __init__(self, size):  # self,要素数
            self.size = size
            self.tree_root = list(range(self.size))
            self.tree_depth = [1]*self.size

        # rootを探す
        def root(self, index):
            temp_list = []
            temp = self.tree_root[index]
            while index != temp:
                temp_list.append(index)
                index = temp
                temp = self.tree_root[index]
            for i in temp_list:
                self.tree_root[i] = index
            return index

        # 結合
        def unite(self, index1, index2):
            r1 = self.root(index1)
            r2 = self.root(index2)
            if r1 != r2:
                d1, d2 = self.tree_depth[r1], self.tree_depth[r2]
                if d1 <= d2:
                    self.tree_root[r1] = r2
                    self.tree_depth[r2] = max(d1+1, d2)
                else:
                    self.tree_root[r2] = r1
                    self.tree_depth[r1] = max(d2+1, d1)

        # 同じか判定
        def same(self, index1, index2):
            r1 = self.root(index1)
            r2 = self.root(index2)
            return r1 == r2

        # 連結成分の個数
        def component(self):
            return len({self.root(i) for i in range(self.size)})

    u = unionfind(2*n)

    for w, x, y, z in wxyz:
        x -= 1
        y -= 1
        if w == 1:
            if z % 2 == 0:
                u.unite(x, y)
                u.unite(x+n, y+n)
            else:
                u.unite(x, y+n)
                u.unite(x+n, y)
        else:
            print(["NO", "YES"][u.same(x, y) or u.same(x+n, y+n)])


main()


### FIXED CODE ###

def main():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    ab = [list(map(int, input().split())) for _ in [0]*m]
    g = [[] for _ in [0]*n]
    [g[a-1].append(b-1) for a, b in ab]
    [g[b-1].append(a-1) for a, b in ab]

    cnt = 0
    for i in range(n):
        hh = h[i]
        for j in g[i]:
            if h[j] >= hh:
                break
        else:
            cnt += 1
    print(cnt)


main()
N, L = list(map(int, input().split()))

for i in range(1, N+1):
    apple_pie = 0
    apple_pie += L + i - 1

for k in range(1, N+1):
    ab = []
    ab += abs(L + k - 1)

if min(ab):
    print(apple_pie - (L + ab.index(min(ab))  ))

### FIXED CODE ###

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

apple_pie = 0
for i in range(1, N+1):
    apple_pie += L + i - 1

ab = []
for k in range(1, N+1):
    ab.append(abs(L + k - 1))

print(apple_pie - (L + ab.index(min(ab))  ))
P=[int(input()) for i in range(int(input()))]
print(sum(p)-max(p)//2)


### FIXED CODE ###

P=[int(input()) for i in range(int(input()))]
print(sum(P)-max(P)//2)
import math

x = input().split(" ")
a = int(x[0])
b = int(x[1])
c = int(x[2])
d = int(x[3])

c_count = (b//c)-((a-1)//c)
d_count = (b//d)-((a-1)//d)

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

print((b+1-a)-c_count-d_count+cd_count)

### FIXED CODE ###

import fractions

x = input().split(" ")
a = int(x[0])
b = int(x[1])
c = int(x[2])
d = int(x[3])

c_count = (b//c)-((a-1)//c)
d_count = (b//d)-((a-1)//d)

cd = c*d // fractions.gcd(c,d)
cd_count = (b//cd) - ((a-1)//cd)
ans = (b+1-a)-c_count-d_count+cd_count

print(ans)
# UnionTreeクラス：グループ分けを木構造で管理する
class UnionFind():
    def __init__(self, N):
        self.par = [i for i in range(N)]
        self.size = [1] * N
        self.N = N

    # xのrootを返す
    def root(self, x):
        if self.par[x] == x:
            return x
        else: 
            self.par[x] = self.root(self.par[x])
            return self.root(self.par[x])

    # x, yが同じrootの場合true
    def same(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        return rx == ry

    # x,yのrootが違った場合、併合
    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        if self.size[rx] < self.size[ry]:
            self.par[rx] = ry
            self.size[ry] += self.size[rx]
        else:
            self.par[ry] = rx
            self.size[rx] += self.size[ry]

n, m = (int(i) for i in input().split())
input_arr = [[int(i) for i in input().split()] for i in range(m)] 

uf = UnionFind(n)
#input_arr = [[1,2],[3,4],[1,3],[2,3],[1,4]]

#print(output(uf))
result = [n*(n-1)/2]
for i in input_arr[::-1]:
    a = i[0]-1
    b = i[1]-1
    if not uf.same(a,b):
        x = uf.size[uf.root(a)] * uf.size[uf.root(b)]
        uf.unite(a,b)
        result.append(result[-1]-x)
    else:
        result.append(result[-1])

for i in result[::-1][1:]:
    print(i)

#print(uf.par)


### FIXED CODE ###

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

result = b / a
result = int(min(result, c))
print(result)
#080_A
n,a,b=map(int,input().split())
print(min(a*t,b))

### FIXED CODE ###

#080_A
n,a,b=map(int,input().split())
print(min(a*n,b))
a,b,c=map(int,input().split())
a,b,c=sorted([a+(a%2==b%2 xor a%2==c%2),b+(b%2==a%2 xor b%2==c%2),c+(c%2==a%2 xor c%2==b%2)])
print((c-a)//2+(c-b)//2+(a%2!=b%2 or b%2!=c%2))

### FIXED CODE ###

a,b,c=map(int,input().split())
if a%2==b%2 and b%2==c%2:
    x=sorted([a,b,c])
    print((x[2]-x[1])//2+(x[2]-x[0])//2)
elif a%2==b%2:
    a+=1
    b+=1
    x=sorted([a,b,c])
    print((x[2]-x[1])//2+(x[2]-x[0])//2+1)
elif b%2==c%2:
    b+=1
    c+=1
    x=sorted([a,b,c])
    print((x[2]-x[1])//2+(x[2]-x[0])//2+1)
else:
    c+=1
    a+=1
    x=sorted([a,b,c])
    print((x[2]-x[1])//2+(x[2]-x[0])//2+1)
import math
N,K = map(int,input().split())


print(sum([(1/N)*(0.5)**math.ceil(math.log2(max(K//i,1))) for i in range(1,N+1)])

### FIXED CODE ###

import math
N,K = map(int,input().split())


print('{:.12f}'.format(sum([(1/N)*(0.5)**math.ceil(math.log2(math.ceil(K/i))) if i<K else 1/N for i in range(1,N+1)])))
import sys
from collections import defaultdict

sys.setrecursionlimit(10 ** 7)
# ----------

INF = float("inf")
MOD = 10 ** 9 + 7
# ----------

def get_count(x):
    if x == 2:
        return 1
    s = set()
    i = 1
    while x:
        if x - i in s:
            break
        s.add(i)
        x -= i
        i += 1
    return len(s)



N = int(input())

if N == 1:
    print(0)
    exit()

e = defaultdict(int)
for i in range(2, int(N ** 0.5) + 1):
    while N % i == 0:
        e[i] += 1
        N //= i

if len(e) == 0:
    print(1)
    exit()

ans = 0
for k, v in e.items():
    ans += get_count(v)
print(ans)

### FIXED CODE ###

from collections import defaultdict

N = int(input())

if N == 1:
    print(0)
    exit()

e = defaultdict(int)
for i in range(2, int(N ** 0.5) + 1):
    while N % i == 0:
        e[i] += 1
        N //= i
if N != 1:
    e[N] += 1


if len(e) == 0:
    print(1)
    exit()

ans = 0
for k, v in e.items():
    tmp = 0
    i = 0
    while tmp + i + 1 <= v:
        i += 1
        tmp += i
    ans += i

print(ans)
n, m, l, = [int(i) for i in input().split()]

A = []
B = []
C = []

for ni in range(n):
    A.append([int(i) for i in input().split()])

for mi in range(m):
    B.append([int(i) for i in input().split()])

for i in range(n):
    for j in range(l):
        C[i].append(0)
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]

for li in range(n):
    print(" ".join([str(s) for s in C[li]]))

### FIXED CODE ###

n, m, l = [int(i) for i in input().split()]
 
A = []
B = []
C = []
for ni in range(n):
    A.append([int(i) for i in input().split()])
 
for mi in range(m):
    B.append([int(i) for i in input().split()])
 
for i in range(n):
    C.append([])
    for j in range(l):
        C[i].append(0)
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]
 
for ni in range(n):
    print(" ".join([str(s) for s in C[ni]]))
import numpy as np
n,q = map(int, input().split())
A = np.array([None] * n)
for i in range(q):
 c,x,y = map(int,input().split())
 if c == 0:
  A[x] = y
 else:
  a = np.min(A[x:y+1])
  if a is None: a = "2147483647"
  else: a = str(a)
  print(a)

### FIXED CODE ###

import math, sys
MAX = pow(2, 31) - 1

#??°????????????????????§????°????????????¨???????????°??????????????????????§????
class SegmentTree():
    def __init__(self, n):
        self.TreeRange = pow(2, math.ceil(math.log2(n)))
        self.List = [MAX] * (2 * self.TreeRange - 1)

    def update(self, i, x):
        i += self.TreeRange - 1
        self.List[i] = x
        while i > 0:
            i = (i - 1) // 2
            self.List[i] = min (self.List[i * 2 + 1], self.List[i * 2 + 2])

    def find(self, s, t, i=0, left=0, right=float("inf")):
        #??¢?´¢????±?????????????????????§????????°?????§???????????????
        if right <= s or t <= left:
            return MAX
        #??¢?´¢????±?????????????????????§????????°??????????????????????????????
        elif s <= left <= right <= t:
            return self.List[i]
        #??¢?´¢????±????????????????????????????????????°????????????????????°
        else:
            l = self.find(s, t, i * 2 + 1, left, (left + right) // 2)
            r = self.find(s, t, i * 2 + 2, (left + right) // 2, right)
            return min(l, r)

_input = sys.stdin.readlines()
n,q = map(int, _input[0].split())
qlist = map(lambda x:x.split(), _input[1:])
ST = SegmentTree(n)

for q in qlist:
    cmd, x, y = map(int, q)
    if cmd == 0:
        ST.update(x, y)
    elif cmd == 1:
        print(ST.find(x,y + 1, right = ST.TreeRange))
N,K=map(int,input().split())
tree=[[]for _ in range(N+1)]
MOD=10**9+7
ans=K
for i in range(N-1):
    a,b=map(int,input().split())
    tree[a].append(b)
    tree[b].append(a)
def comb(a,b):
    x,y=1,1
    for i in range(b):
        x*=a-i
        y*=i+1
        x%=MOD
        y%=MOD
    return (x*pow(y,MOD-2,MOD))%MOD
def cal(a):
    num=1
    for i in range(1,a+1):
        num*=i
    return num
def dfs(a,b):
    if a==1:
        node=len(tree[a])
        ret=cal(node)*comb(K-1,node)%MOD
    else:
        node=len(tree[a])-1
        ret=cal(node)*comb(K-2,node)%MOD
    for i in tree[a]:
        if i==b:
            continue
        ret=ret*dfs(i,a)%MOD
    return max(ret,1)
ans*=dfs(1,0)
print(ans%MOD)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 6)
N,K=map(int,input().split())
tree=[[]for _ in range(N+1)]
MOD=10**9+7
ans=K
enuk=[1]*(N)
for i in range(N-1):
    a,b=map(int,input().split())
    tree[a].append(b)
    tree[b].append(a)
    enuk[i+1]=(enuk[i]*(K-2-i))%MOD
def dfs(a,b):
    if a==1:
        node=len(tree[a])
        ret=1
        for i in range(node):
            ret*=K-1-i
            ret%=MOD
    else:
        node=len(tree[a])-1
        ret=enuk[node]%MOD
    for i in tree[a]:
        if i==b:
            continue
        ret=ret*dfs(i,a)%MOD
    return ret
ans*=dfs(1,0)
print(ans%MOD)
n, k = map(int, input().split())
mod = 10 ** 9 + 7

fact = [1] * (n + 1)
for i in range(2, n + 1):
  fact[i] = fact[i-1] * i % mod
inv_fact = [1] * (n + 1)
inv_fact[n] = pow(fact[n], mod - 2, mod)
for i in range(n - 1, 1, -1):
  inv_fact[i] = inv_factor[i + 1] * (i + 1) % mod

def comb(_n: int, _k: int) -> int:
  return fact[_n] * inv_fact[_n - _k] * inv_vact[_k] % mod

for i in range(1, k + 1):
  red = n - k
  if i > red + 1:
    print(0)
  else:
    print(comb(red + 1, i) * comb(k - 1, k - i) % mod)

### FIXED CODE ###

n, k = map(int, input().split())
mod = 10 ** 9 + 7

fact = [1] * (n + 1)
for i in range(2, n + 1):
  fact[i] = fact[i-1] * i % mod
inv_fact = [1] * (n + 1)
inv_fact[n] = pow(fact[n], mod - 2, mod)
for i in range(n - 1, 1, -1):
  inv_fact[i] = inv_fact[i + 1] * (i + 1) % mod

def comb(_n: int, _k: int) -> int:
  return fact[_n] * inv_fact[_n - _k] * inv_fact[_k] % mod

for i in range(1, k + 1):
  red = n - k
  if i > red + 1:
    print(0)
  else:
    print(comb(red + 1, i) * comb(k - 1, k - i) % mod)
N=int(input())
A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
B1=[0*i for i in range(N)]
B2=[0*i for i in range(N)]

B1[0]=A1[0]
B2=[0]=A2[0]
for i in range(0,N-1):
    B1[i+1]=B1[i]+A1[i+1]
    B2[i+1]=B2[i]+A2[i+1]
maximum=B1[0]+B2[N-1]
for i in range(1,N):
    point=B1[i]+(B2[N-1]-B2[i-1])
    maximum=max(maximum,point)
print(maximum)


### FIXED CODE ###

N=int(input())
A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
B1=[0*i for i in range(N)]
B2=[0*i for i in range(N)]

B1[0]=A1[0]
B2[0]=A2[0]
for i in range(0,N-1):
    B1[i+1]=B1[i]+A1[i+1]
    B2[i+1]=B2[i]+A2[i+1]
maximum=B1[0]+B2[N-1]
for i in range(1,N):
    point=B1[i]+(B2[N-1]-B2[i-1])
    maximum=max(maximum,point)
print(maximum)
import collectinos
n = int(input())
s = input()

c = collections.Counter(s)

res = 1
for x in c.values():
    res *= (x+1)

print( (res-1) % (10**9 + 7))

### FIXED CODE ###

import collections
n = int(input())
s = input()

c = collections.Counter(s)

res = 1
for x in c.values():
    res *= (x+1)

print( (res-1) % (10**9 + 7))
n = input()

for i in range(n):
  R[i] = input()

max = 0

for i in range(n):
  for j in range(i):
    d = R[i] - R[j]
    if max < d:
      max = d

print max

### FIXED CODE ###

n = input()
maxi = -1 * 10**9
mini = input()


for i in range(n-1):
  tmp = input()
  maxi = max(maxi, tmp - mini)
  mini = min(mini, tmp)

print maxi