Harryxun/stf_run huggingface dataset:
from collections import deque
import sys

class Tree:
    def __init__(self, n, init_list, root=1):
        self.num = (n + 1)
        self.parents = [-1] * self.num
        self.first_child = [-1] * self.num
        self.next_child = [-1] * self.num
        self.check = [-1] * self.num
        self.g = {i: [] for i in range(1, self.num)}
        self.make_g(init_list, root)

    def make_g(self, con, root):
        m = len(con)
        for i in range(m):
            self.g[con[i][0]].append(con[i][1])
            self.g[con[i][1]].append(con[i][0])
        q = deque([root])
        while q != deque():
            node = q.pop()
            self.check[node] = 1
            cnt = 0
            for i, sub_node in enumerate(self.g[node]):
                if self.check[sub_node] != -1:
                    continue
                if cnt == 0:
                    self.first_child[node] = sub_node
                self.parents[sub_node] = node
                if i != len(self.g[node])-1:
                    self.next_child[sub_node] = self.g[node][i+1]
                q.append(sub_node)
                cnt += 1

    def childs(self, node):
        child_list = []
        if self.first_child[node] != -1:
            child_list.append(self.first_child[node])
            node = self.first_child[node]
            while 1:
                if self.next_child[node] == -1:
                    break
                else:
                    child_list.append(self.next_child[node])
                node = self.next_child[node]
        return child_list

    def parent(self, n):
        return self.parents[n]

input = sys.stdin.readline
N, Q = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N-1)]
P = [0] * Q
X = [0] * Q
V = [0] * (N + 1)
for i in range(Q):
    P, X = map(int, input().split())
    V[P] += X

tr = Tree(N, AB)

q = deque()
q.extend(tr.childs(1))
while q != deque():
    node = q.pop()
    V[node] += V[tr.parent(node)]
    if tr.childs(node):
        q.extend(tr.childs(node))

print(*V[1:])


### FIXED CODE ###

N = int(input())
AB = [list(map(int, input().split())) for _ in range(N-1)]
sortedAB = sorted(AB)
con = {i: [] for i in range(1, N+1)}
color = [0] * (N + 1)
for a, b in sortedAB:
    con[a].append(b)

for i in range(1, N + 1):
    now_c = 1
    for c in con[i]:
        if color[i] == now_c:
            now_c += 1
        color[c] = now_c
        now_c += 1

print(max(color))
for i in range(N-1):
    print(color[AB[i][1]])

a = 0
a = int(input())
b = int(input())
if 1<=a<=100 and 1<=b<=100:
  return a*b

### FIXED CODE ###

a,b = map(int,input().split())
print(a*b)
s = input()
if s.isupps = input()
if s.isupper():
    print('A')
else:
    print('a')

### FIXED CODE ###

a = input()
print('a' if a.islower() else 'A')
import numpy as np

n = int(input())
a = list(map(int, input().split()))

a = list(set(a))

count = 0
for i in range(n):
    ans = a[i] % np.array(a)
    if np.count_nonzero(ans == 0) == 1:
        count += 1

print(count)


### FIXED CODE ###

n = int(input())
a = sorted(list(map(int, input().split())))

a_max = a[-1]
dp = [1]*a_max

for i in set(a):
    j = 2
    while i*j <= a_max:
        dp[i*j-1] = 0
        j += 1

a.append(0)
ans = 0
for i in range(n):
    if dp[a[i]-1] and a[i-1] != a[i] and a[i] != a[i+1]:
        ans += 1
print(ans)
I=int(input().split())
x=int(input().split())
y=int(input().split())

if (min(y,I[3])-max(x,I[2]))>0:
    print('No War')
    
else :
    print('War')

### FIXED CODE ###

N,M,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))

x.append(X)
y.append(Y)

if (min(y)-max(x))>0:
    print('No War')
    
else :
    print('War')
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict, deque

H,W=map(int, sys.stdin.readline().split())
CH,CW=map(int, sys.stdin.readline().split())
CH-=1
CW-=1
DH,DW=map(int, sys.stdin.readline().split())
DH-=1
DW-=1
S=[ sys.stdin.readline().strip() for _ in range(W) ]

D=[(0,1),(0,-1),(1,0),(-1,0)]
WARP=[]
for dh in range(-2,3):
    for dw in range(-2,3):
        if abs(dh)+abs(dw)<=1: continue
        WARP.append((dh,dw))

d=defaultdict(lambda: float("inf")) #スタート地点から各マスまでの距離

q=deque()
q.append((0,CH,CW))
d[(CH,CW)]=0

while q:
    kyori, fro_h, fro_w=q.popleft()
    if d[(fro_h, fro_w)]<kyori: continue
    #歩いて移動
    for dh,dw in D:
        to_h, to_w=fro_h+dh, fro_w+dw
        if 0<=to_h<H and 0<=to_w<W and S[to_h][to_w]==".":
            if kyori < d[(to_h, to_w)]:
                d[(to_h, to_w)]=kyori
                q.appendleft((kyori, to_h, to_w))
    #ワープ
    for dh,dw in WARP:
        to_h, to_w=fro_h+dh, fro_w+dw
        if 0<=to_h<H and 0<=to_w<W and S[to_h][to_w]==".":
            if kyori+1 < d[(to_h, to_w)]:
                d[(to_h, to_w)]=kyori+1
                q.append((kyori+1, to_h, to_w))

if d[(DH,DW)]==float("inf"):
    print -1
else:
    print d[(DH,DW)]


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
from collections import defaultdict, deque

H,W=map(int, sys.stdin.readline().split())
CH,CW=map(int, sys.stdin.readline().split())
CH-=1
CW-=1
DH,DW=map(int, sys.stdin.readline().split())
DH-=1
DW-=1
S=[ sys.stdin.readline().strip() for _ in range(H) ]

D=[(0,1),(0,-1),(1,0),(-1,0)]
WARP=[]
for dh in range(-2,3):
    for dw in range(-2,3):
        if abs(dh)+abs(dw)<=1: continue
        WARP.append((dh,dw))

d=defaultdict(lambda: float("inf")) #スタート地点から各マスまでの距離

q=deque()
q.append((0,CH,CW))
d[(CH,CW)]=0

while q:
    kyori, fro_h, fro_w=q.popleft()
    if d[(fro_h, fro_w)]<kyori: continue
    #歩いて移動
    for dh,dw in D:
        to_h, to_w=fro_h+dh, fro_w+dw
        if 0<=to_h<H and 0<=to_w<W and S[to_h][to_w]==".":
            if kyori < d[(to_h, to_w)]:
                d[(to_h, to_w)]=kyori
                q.appendleft((kyori, to_h, to_w))
    #ワープ
    for dh,dw in WARP:
        to_h, to_w=fro_h+dh, fro_w+dw
        if 0<=to_h<H and 0<=to_w<W and S[to_h][to_w]==".":
            if kyori+1 < d[(to_h, to_w)]:
                d[(to_h, to_w)]=kyori+1
                q.append((kyori+1, to_h, to_w))

if d[(DH,DW)]==float("inf"):
    print -1
else:
    print d[(DH,DW)]
s=input().replace('\n', '')
t=input().replace('\n', '')
begin, end = len(s) - len(t), len(s)
ans=''
while begin>=0:
    origin = s[begin:end]
    flag=1
    for i in range(len(t)):
        if origin[i]!=t[i] and origin[i]!='?':
            flag=0
            break
    if flag:
        ans = s[:begin]+t+s[end:]
    begin-=1
    end-=1
print("UNRESTORABLE" if flag else ans.replace('?', 'a'))


### FIXED CODE ###

s=input().replace('\n', '')
t=input().replace('\n', '')
begin, end = len(s) - len(t), len(s)
ans=''
while begin>=0:
    origin = s[begin:end]
    flag=1
    
    for i in range(len(t)):
        if origin[i]!=t[i] and origin[i]!='?':
            flag=0
            break
    if flag:
        ans = s[:begin]+t+s[end:]
        break
    begin-=1
    end-=1
print("UNRESTORABLE" if not len(ans) else ans.replace('?', 'a'))
def func(k):
    
    while k < 55555 :
        k += 1
        b=k
        for j in a:
            if k%j==0:
                b=0
    
        if b==k:
            return k
            break
            
        
n=int(input())
a=[]

k=2
for i in range(55):
    a.append(func(k))

ans=[]
for j in range(len(a)):
    if len(ans) <= n:
        if a[j] % 5 == 1:
            ans.append(a[j])
 
 print(*ans)

### FIXED CODE ###

def main():
    n=int(input())
    a=[]
    s=[]
    t=0
    for k in range(3,55556):
        b=k
        for j in s:
            if k%j==0:
                b=0
        if b==k:
            s.append(k)
            if k % 5 == 1:
                if t < n:
                    a.append(k)
                    t += 1
                else:
                    break
     
    print(*a)
    
    
    
main()
r,g,b=map(int,input().split())
x=int(r+g+b)
if x%4==0:
  print('YES')
else:
  print('NO')
r,g,b=map(int,input().spklit())
x=int(r+g+b)
if x%4==0:
  print('YES')
else:
  print('NO')


### FIXED CODE ###

r,g,b=input().split()
x=int(r+g+b)

if x%4==0:
  print('YES')
else:
  print('NO')
x = input('sample1:')
x = x**3
print(x)



### FIXED CODE ###

x = int(input())
print(x**3)
# -*- encode utf-8 -*-
#羊の数と狼の数を入力
S,W = int(input())
狼の数が羊の数以上のとき、羊は狼に襲われてしまいます。
if 2W >= S:
	print(unsafe)
else:
	print(safe)


### FIXED CODE ###

s,w = input().split()
if int(w) >= int(s):
  print('unsafe')
else:
  print('safe')
N, X = map(int, input().split())
a,p=[1],[1] for i in range(N):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)
def f(N,X): #X<=0やX>a_Nを許容し解説本文から簡略化
  if N == 0:
    return 0 if X <= 0 else 1
  elif X <= 1 + a[N-1]:
    return f(N-1, X-1)
  else:
    return p[N-1] + 1 + f(N-1, X-2-a[N-1])
print(f(N, X))

### FIXED CODE ###

n,k = map(int,input().split())
a,p = [1],[1]
for i in range(n):
  a.append(a[i]*2+3)
  p.append(p[i]*2+1)
def f(n,k):
  if n == 0:
    if k == 0:
      return 0
    else:
      return 1
  if k == 0:
    return 0
  elif k <= a[n-1]+1:
    return f(n-1,k-1)
  else:
    return p[n-1]+1+f(n-1,k-2-a[n-1])
print(f(n,k))
n, k = map(int, input().split())
A = list(map(int, input().split()))
def f(x):
    return A[x-1]
c = 1
P = [1]
 
for i in range(1,k+1):
    c = f(c)
    if c in P:
        roop_start = P.index(c)
        roop_num = i- roop_start
        break
    P.append(c)
a = (k - roop_start) %  roop_num
for i in range(a):
    P[roop_start] = f(P[roop_start])
print(P[roop_start])

### FIXED CODE ###

n, k = map(int, input().split())
A = list(map(int, input().split()))
now = 1
 
for i in range(len(bin(k))-2):
    if (k>>i)&1:
        now = A[now-1]
    A = [A[a-1] for a in A]
print(now)
import sys
input = sys.stdin.readline
import numpy as np
base_list = np.array(['A','B','C','D','E','F','G','F','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'])
dict_list = []
dict_list.append(base_list)
for i in range(25):
    tmp_char = dict_list[i][0]
    tmp_list = dict_list[i][1:]
    tmp_list = np.append(tmp_list,tmp_char)
    dict_list.append(tmp_list)

def print_ans(N, sr):
    """Test Case
    >>> print_ans(2, ['A', 'B', 'C', 'X', 'Y', 'Z'])
    CDEZAB
    >>> print_ans(0, ['A', 'B', 'C','X', 'Y', 'Z'])
    ABCXYZ
    """
    idx_list = []
    for s in sr:
        tmp = np.where(base_list == s)[0]
        idx_list.append(int(tmp))
    print(''.join(dict_list[N][idx_list]))

if __name__ == '__main__':
    N = int(input().rstrip())
    tmp_s= input().rstrip()
    sr = []
    for s in tmp_s:
        sr.append(s)
    print_ans(N, sr)




### FIXED CODE ###

import sys
input = sys.stdin.readline
import numpy as np
base_list = np.array(['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'])
dict_list = []
dict_list.append(base_list)
for i in range(26):
    tmp_char = dict_list[i][0]
    tmp_list = dict_list[i][1:]
    tmp_list = np.append(tmp_list,tmp_char)
    dict_list.append(tmp_list)

def print_ans(N, sr):
    """Test Case
    >>> print_ans(2, ['A', 'B', 'C', 'X', 'Y', 'Z'])
    CDEZAB
    >>> print_ans(0, ['A', 'B', 'C','X', 'Y', 'Z'])
    ABCXYZ
    """
    idx_list = []
    for s in sr:
        tmp = np.where(base_list == s)[0]
        idx_list.append(int(tmp))
    ans = ''.join(dict_list[N][idx_list])
    print(ans)

if __name__ == '__main__':
    N = int(input().rstrip())
    tmp_s= input().rstrip()
    sr = []
    for s in tmp_s:
        sr.append(s)
    print_ans(N, sr)
A, op, B = input().split()
A, B = int(A), int(B)
if op == '+'
    print(A + B)
else:
    print(A - B)

### FIXED CODE ###

print(eval(input()))
lst =map(int, input().split())

max_value = 0
for i in range(len(lst)):
  for j in range(i):
    max_value = max(max_value, lst[i]*lst[j])

print(max_value)

### FIXED CODE ###

# -*- coding: utf-8 -*-
# map(int, input().split())
a,b,c,d = list(map(int, input().split()))
 
max_value = max([a*c,a*d,b*c,b*d])

print(max_value)
n=int(input())
arr=list(map(int,input().split()))
vis={}
vis[0] = 0
if n < 2:
  print(0)
if n == 2:
  print(min(arr[0]-arr[1]))
vis[1] = min(arr[0]-arr[1])
def count(n):
    if n < 0:
      return 0
    if n in vis:
        return vis[n]
    else:
      vis[n]=min(abs(arr[n-1]-arr[n-2])+count(n-1),abs(arr[n-1]-arr[n-3])+count(n-2))
    return vis[n]
print(count(n-1))

### FIXED CODE ###

n=int(input())
arr=list(map(int,input().split()))
if n < 2:
  print(0)
vis = [0] * n
vis[0] = 0
vis[1] = abs(arr[0]-arr[1])
for i in range(2, n):
    step_1 = abs(arr[i]-arr[i-1]) + vis[i-1]
    step_2 = abs(arr[i]-arr[i-2]) + vis[i-2]
    vis[i] = min(step_1, step_2)
print(vis[-1])
import sys

n=int(raw_input())
buf =[[] for i in range(n)]

while True:
    text = raw_input().split()
    if text[0] == 'quit':
        break
    elif text[0] == 'push':
        buf[int(text[1])-1].append(text[2])
    elif text[0] == 'pop':
        print buf[int(text[1])-1][-1]
        buf[text[1]].pop()
    elif text[0] == 'move':
        buf[int(text[2])-1].append(buf[int(text[1])-1][-1])
        buf[int(text[1])].pop()

### FIXED CODE ###

import sys

n=int(raw_input())
buf =[[] for i in range(n)]

while True:
    text = raw_input().split()
    if text[0] == 'quit':
        break
    elif text[0] == 'push':
        buf[int(text[1])-1].append(text[2])
    elif text[0] == 'pop':
        print buf[int(text[1])-1][-1]
        buf[int(text[1])-1].pop()
    elif text[0] == 'move':
        buf[int(text[2])-1].append(buf[int(text[1])-1][-1])
        buf[int(text[1])-1].pop()
feom collections import sqrt
if __name__=='__main__':
  n,d=[int(i) for i in input().split()]
  c=0
  for i in range(n):
    x,y = [int(i) for i in input().split()]
    if sqrt(x**2 + y**2) <= d:
      c+=1
  print(c)
    

### FIXED CODE ###

from math import sqrt
if __name__=='__main__':
  n,d=[int(i) for i in input().split()]
  c=0
  for i in range(n):
    x,y = [int(i) for i in input().split()]
    if sqrt(x**2 + y**2) <= d:
      c+=1
  print(c)
n = int(input())
blue = {}
for _ in range(n):
  s = input()
  blue[s] += 1
m = int(input())
red = {}
for _ in range(m):
  t = input()
  red[t] += 1
res = -100
for key, value in blue:
  tmp = 0
  if(key in red):
    tmp = blue[key] - red[key]
  else:
    tmp = blue[key]
  if(tmp > res):
    res = tmp
print(res)

### FIXED CODE ###

n = int(input())
blue = {}
for _ in range(n):
  s = input()
  if(s in blue):
    blue[s] += 1
  else:
    blue[s] = 1
m = int(input())
red = {}
for _ in range(m):
  t = input()
  if(t in red):
    red[t] += 1
  else:
    red[t] = 1
res = -100
for key, value in blue.items():
  tmp = 0
  if(key in red):
    tmp = blue[key] - red[key]
  else:
    tmp = blue[key]
  if(tmp > res):
    res = tmp
if(res >= 0):
  print(res)
else:
  print(0)
n=int(input())
a=list(map(int,input().split()))
a.sort()
A=[a[0]]
x=0
sum=sum(a)
sumL=-9999999999
if n==2:
  print(max(a)-min(a))
  print(max(a),min(a))
else:
  for i in range(1,n):
    A.append(A[i-1]+a[i])
  for i in range(1,n):
    if sumL<-A[i-1]+sum-A[i-1]:
      sumL=-A[i-1]+sum-A[i-1]
      x=i
  print(sumL)
  L1=a[0:x]
  L2=a[x:n]

  if x!=1:
    print(L2[0],L1[0])
    z=L2[0]-L1[0]
    for i in range(1,x-1):
      print(z,L1[i])
      z=z-L1[i]
  else:
    z=L2[0]

  print(L1[x-1],L2[1])
  y=L1[x-1]-L2[1]
  for i in range(2,len(L2)):
    print(y,L2[i])
    y=y-L2[i]

  print(z,y)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
a.sort()
A=[a[0]]
x=0
sum=sum(a)
sumL=-9999999999
if n==2:
  print(max(a)-min(a))
  print(max(a),min(a))
else:
  for i in range(1,n):
    A.append(A[i-1]+a[i])
  for i in range(1,n):
    if sumL<-A[i-1]+sum-A[i-1]:
      sumL=-A[i-1]+sum-A[i-1]
      x=i
  print(sumL)
  L1=a[0:x]
  L2=a[x:n]

  if x!=1:
    print(L2[0],L1[0])
    z=L2[0]-L1[0]
    for i in range(1,x-1):
      print(z,L1[i])
      z=z-L1[i]
  else:
    z=L2[0]

  if x!=n-1:
    print(L1[x-1],L2[1])
    y=L1[x-1]-L2[1]
    for i in range(2,len(L2)):
      print(y,L2[i])
      y=y-L2[i]
  else:
    y=L1[len(L1)-1]

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

import numpy as npz

ans = 0
for i in range(N):
    c = list(A[i]%np.array(A))
    if A.count(A[i]) == N:
        ans = 0
        break
        break
    if c.count(0) == 1:
        ans += 1
print(ans)

### FIXED CODE ###

from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
p = [True] * (10 ** 6 + 1)
s = list(set(a))
for x in s:
    t = x * 2
    while t <= 10 ** 6:
        p[t] = False
        t += x
ans = 0
for x in a:
    if c[x] == 1 and p[x] == True:
        ans += 1
print(ans)
# coding: utf-8
import string
 
n = int(input())
a = list(map(int,input().split()))
res = 1
for i in range(n):
    res *= a[i]
    if(res>pow(10,18)):
      	break
 
if(res>pow(10,18)):
    print(-1)
else:
    print(res)

### FIXED CODE ###

# coding: utf-8
import string

n = list(map(int,input().split()))
print(n[0]*n[1])
import string
d = {c:ord(c)-97 for c in string.ascii_lowercase}
b = {v:k for k, v in d.items()}
while True:
    try:
        s = input()
    except:
        break
    t = 0
    for token in list(filter(lambda x: len(x) in [3, 4], s[:-1].split())):
        t = d[token[0]]%26-19
        word = ''.join([b[d[c]%26-t] for c in token])
        if word in ['the', 'that', 'this']:
            break
    ans = [' ' if c == ' ' else b[d[c]%26-t] for c in s[:-1]]+['.']
    print(''.join(ans))

### FIXED CODE ###

import string
strings = string.ascii_lowercase
clues = [(19, 7, 8, 18), (19, 7, 0, 19), (19, 7, 4)]
while True:
    try:
        data = input()
    except:
        break
    for word in data.split():
        if len(word) == 4 or 3:
            dif = 19 - (ord(word[0]) - 97)
            enc = ["" for _ in range(26)]
            for k, v in zip([i for i in range(dif, dif+26)], strings):
                enc[k%26] = v
            candidate = tuple(enc.index(c) for c in word)
            try:
                clues.index(candidate)
            except:
                continue
            break
    ans = ""
    for c in data:
        try:
            ans += strings[enc.index(c)]
        except:
            ans = ans + "." if c == "." else ans + " "
    print(ans)
import math
a,b,c=map(int,input().split())
print('YES' if c%(math.gcd(a,b))==0 else 'NO')

### FIXED CODE ###

import fractions as f
a,b,c=map(int,input().split())
print('YES' if c%(f.gcd(a,b))==0 else 'NO')
kis = input()
gus = input()
a = len(kis)
b = len(gus)
c = ""
if a == b:
 for i in range(a) :
  c += kis[i] + gus[i]
else:
  for i in range(b): 
   c += kis[i] + gus[i]
  c += kis[a-1]

print(c)

### FIXED CODE ###

a = list(map(int, input().split()))
if a[0] -a[1] == a[1] - a[2]:
 print("YES")
else:
 print("NO")
a = input().split()
a = [int(i) for i in a]

a[0] = a[0] % 2019
a[1] = a[1] % 2019
yojyou_list=[]
if a[0] > a[1]:
    for i in range(a[0]-a[1]):
        yojyou_list.append((a[1] + i) % 2019)
else:
    for i in range(a[1] - a[0]):
        yojyou_list.append((a[0] + i) % 2019)


yojyou_list = list(set(yojyou_list))
yojyou_list=sorted(yojyou_list)

    
print((yojyou_list[0] * yojyou_list[1]) % 2019)

### FIXED CODE ###

a = input().split()
a = [int(i) for i in a]
a = sorted(a)
if a[0] + 2019 <= a[1]:
    print(0)
else:
    b_1 = [i for i in range(a[0], a[1] + 1)]
    c = [i % 2019 for i in b_1]
    c = sorted(c)
    epoc = 2019
    for i in range(len(c)):
        for u in range(i):
            epoc1 = (c[i] * c[u]) % 2019
            if epoc1 < epoc:
                epoc = epoc1

    print(epoc)
from functools import reduce
import math
from collections import defaultdict

MIN = -10 ** 9
MAX = 10 ** 9 + 7

from math import factorial


def main():
    N, K = [int(a) for a in input().split()]

    ab = [
        [int(a) for a in input().split()]
        for _ in range(N - 1)
    ]

    edges = defaultdict(lambda: [])
    for ai, bi in ab:
        r = edges[ai]
        r.append(bi)
        edges[ai] = r
        r = edges[bi]
        r.append(ai)
        edges[bi] = r

    def parsetree(parent_i, current_i):
        children = []
        for nei in edges[current_i]:
            if nei == parent_i:
                continue
            child = parsetree(current_i, nei)
            children.append(child)
        return children

    tree = parsetree(None, 1)

    def c(a, b):
        k = 1
        for i in range(b):
            k = (k * (a - i)) % MAX
        return k

    def f(tr):
        childcount = len(tr)
        a = c(K - 2, childcount)
        for child in tr:
            r = f(child) % MAX
            a = (a * r) % MAX
        return a

    result = K * c((K - 1), len(tree))
    for child in tree:
        r = f(child) % MAX
        result = (result * r) % MAX
    print(result)


if __name__ == '__main__':
    main()


### FIXED CODE ###

from collections import defaultdict, deque
import sys
sys.setrecursionlimit(100000)

MIN = -10 ** 9
MAX = 10 ** 9 + 7


def main():
    N, K = [int(a) for a in input().split()]
    if N == 1:
        print(K)
        return
    if K == 1:
        print(0)
        return

    ab = [
        [int(a) for a in input().split()]
        for _ in range(N - 1)
    ]

    edges = defaultdict(lambda: [])
    for ai, bi in ab:
        r = edges[ai]
        r.append(bi)
        edges[ai] = r
        r = edges[bi]
        r.append(ai)
        edges[bi] = r

    childrentable = [None] * (N + 1)

    q = deque()
    q.append((None, 1))

    while len(q) != 0:
        parent_i, current_i = q.pop()

        children = []
        for nei in edges[current_i]:
            if nei == parent_i:
                continue
            q.append((current_i, nei))
            children.append(nei)
        childrentable[current_i] = children

    if len(childrentable[1]) > K - 1:
        print(0)
        return

    def c(a, b):
        k = 1
        for i in range(b):
            if a - i <= 0:
                raise ValueError()
            k = (k * (a - i)) % MAX
        return k

    def f(index):
        target = childrentable[index]
        childcount = len(target)

        a = c(K - 2, childcount)
        for child in target:
            r = f(child) % MAX
            a = (a * r) % MAX
        return a

    try:
        result = K * c((K - 1), len(childrentable[1]))
        for child in childrentable[1]:
            r = f(child) % MAX
            result = (result * r) % MAX
    except:
        print(0)
        return
    print(result)


if __name__ == '__main__':
    main()
from operator import itemgetter
n=int(input())
xl=[list(map(int,input().split()))for i in range(n)]
R=[list(xl[i][0]-xl[i][1],xl[i][0]+xl[i][1]) for i in range(n)]
r=sorted([(R[i][0],R[i][1]) for i in range(n)],key=itemgetter(1))
s=r[0][1]
ans=1
for i in range(n-1):
    if r[i+1][0]>=s:
        s=r[i+1][1]
        ans+=1
print(ans)

### FIXED CODE ###

from operator import itemgetter
n=int(input())
xl=[list(map(int,input().split()))for i in range(n)]
R=[(xl[i][0]-xl[i][1],xl[i][0]+xl[i][1]) for i in range(n)]
r=sorted([(R[i][0],R[i][1]) for i in range(n)],key=itemgetter(1))
s=r[0][1]
ans=1
for i in range(n-1):
    if r[i+1][0]>=s:
        s=r[i+1][1]
        ans+=1
print(ans)
n,k = map(int,input().split())
h = list(map(int,input().split()))

dp = [0]*n
dp[0]=0

for i in range(1,k):
  dp[i]=min([dp[i-j]+abs(h[i]-h[i-j]) for j in range(1,i+1)])

for i in range(k,n):
  dp[i]=min([dp[i-j]+abs(h[i]-h[i-j]) for j in range(1,k+1)])


print(dp[n-1])

### FIXED CODE ###

N,K = map(int,input().split())
h = list(map(int,input().split()))
 
dp = [100000000000]*N
 
dp[0] = 0
dp[1] = abs(h[1]-h[0])
 
for i in range(2,N):
  for num in range(K):
    if num+1<=i:
      A = dp[i-num-1]+abs(h[i]-h[i-num-1])
      if dp[i] >= A:
        dp[i] = A
 
print(dp[N-1])
C = input()
print(C+1)

### FIXED CODE ###

s = input()
print(chr(ord(s)+1))
a,b = map(int,input().split())
for x in range(b * 10,(b + 1) * 10):
    if int(x * 0.08) == a and int(x * 0.1) == b:
        print(x)
        break
else:
    print(-1)

### FIXED CODE ###

s = str(input())
if s == 'BBB' or s == 'AAA':
    print('No')
else:
    print('Yes')