Harryxun/stf_run huggingface dataset:
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def POW(x, y): return pow(x, y, MOD)
def INV(x, m=MOD): return pow(x, m - 2, m)
def DIV(x, y, m=MOD): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

# factorials
_nfact = 10 ** 5 + 10
facts = [0] * _nfact
ifacts = [0] * _nfact
facts[0] = 1
ifacts[0] = 1
for i in range(1, _nfact):
    facts[i] = (facts[i - 1] * i) % MOD
    ifacts[i] = INV(facts[i])

def binomial(m, n):
    return facts[m] * ifacts[n] * ifacts[m - n]

def main():
    N, A, B, C = LI()
    D = DIV(100, 100 - C)
    ans = 0
    for m in range(N, 2 * N):
        x = binomial(m - 1, N - 1) * DIV(
            POW(A, N) * POW(B, m - N) + POW(A, m - N) * POW(B, N),
            POW(A + B, m)) % MOD
        y = (m * D) % MOD
        ans += (x * y) % MOD
    return ans

print(main())

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def POW(x, y): return pow(x, y, MOD)
def INV(x, m=MOD): return pow(x, m - 2, m)
def DIV(x, y, m=MOD): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

# factorials
_nfact = 2 * (10 ** 5) + 10
facts = [0] * _nfact
facts[0] = 1
for i in range(1, _nfact):
    facts[i] = (facts[i - 1] * i) % MOD

def binomial(m, n):
    return DIV(facts[m], facts[n] * facts[m - n])

def main():
    N, A, B, C = LI()
    D = DIV(100, 100 - C)
    ans = 0
    ap, bp, abp = [1], [1], [POW(A + B, N)]
    for _ in range(0, N + 1):
        ap.append(ap[-1] * A % MOD)
        bp.append(bp[-1] * B % MOD)
        abp.append(abp[-1] * (A + B) % MOD)
    for m in range(N, 2 * N):
        x = binomial(m - 1, N - 1) * DIV(
            ap[N] * bp[m - N] + ap[m - N] * bp[N],
            abp[m - N]) % MOD
        y = (m * D) % MOD
        ans = (ans + (x * y) % MOD) % MOD
    return ans

print(main())
# coding: utf-8
# Your code here!

import math
import sys

N, M = map(int, input().rstrip().split(' '))
S = [x for x in input()]
T = [x for x in input()]

def lcm(x, y):
    return int((x * y) / math.gcd(x, y))
    
L = lcm(N, M)
if S[0] != T[0]:
    print(-1)
    sys.exit()
elif L == N or L == M:
    dp = [-1] * L
    for i, s in enumerate(S):
        dp[i*L/N] = s
        
    for i, t in enumerate(T):
        if dp[i*L/M] != -1 and dp[i*L/M] != t:
            print(-1)
            sys.exit()
else:
    print(L)

### FIXED CODE ###

# coding: utf-8
# Your code here!

import fractions
import sys
from collections import defaultdict

N, M = map(int, input().rstrip().split(' '))
S = [x for x in input()]
T = [x for x in input()]

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

L = lcm(N, M)

dp = defaultdict(lambda: -1)

for i, s in enumerate(S):
    dp[i*L//N] = s

for i, t in enumerate(T):
    if dp[i*L//M] != -1:
        if dp[i*L//M] != t:
            print(-1)
            sys.exit()
print(L)
N = int(input())
A = int(input())
B = int(input())

list1 = []
for i in range(N+1):
    s = i//1000 + i//100-1000*(i//1000) + i//10-100*(i//100) +  i-10*(i//10)
    if A <= s <= B:
        list1.append(i)

sum = 0
for j in list1:
    sum += j

print(sum)

### FIXED CODE ###

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

total = 0
for i in range(1, n+1):
    if a <= sum(list(map(int, str(i)))) <= b:
        total += i

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



if (a+b)%2 == 1:
    print (IMPOSSIBLE )

print ((a+b)%2)



### FIXED CODE ###

a, b = map(int, input().split())
if ((a+b)%2) == 1:
    print ('IMPOSSIBLE')
else:
    print ((a+b)//2)
def inpl():
    return list(map(int, input().split()))


def gcd(a, b):
    la = max(a, b)
    sm = min(a, b)
    if la % sm == 0:
        return sm
    else:
        return gcd(sm, la - sm)


n = int(input())
A = inpl()

ans = gcd(A[0], A[1])
for a in A[2:]:
    ans = gcd(ans, a)
print(ans)

### FIXED CODE ###

import sys

sys.setrecursionlimit(20000)


def inpl():
    return list(map(int, input().split()))


def gcd(a, b):
    la = max(a, b)
    sm = min(a, b)
    if la % sm == 0:
        return sm
    else:
        return gcd(sm, la - sm)


n = int(input())
A = inpl()
A.sort()
ans = gcd(A[0], A[1])
for a in A:
    ans = gcd(ans, a)
print(ans)
usrInput = input()
divisor = []
flag = []
finalFlag = False

for kuku in range(9):
    currentDivisor = kuku+1
    if int(usrInput) % currentDivisor == 0:
        divisor.append(currentDivisor)

for x in range(len(divisor)):
    anotherDivisor:float = int(usrInput) / divisor[x]
    if float.is_integer(anotherDivisor) == True and anotherDivisor <= 9 and anotherDivisor > 0 and int(divisor[x]) > 0:
        flag.append(True)
    else:
        flag.append(False)

for n in range(len(divisor)):
    if bool(flag[n]) == True:
        finalFlag = True

if finalFlag == True:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

usrInput = input()
divisor = []
flag = []
finalFlag = False

for kuku in range(9):
    currentDivisor = kuku+1
    if int(usrInput) % currentDivisor == 0:
        divisor.append(currentDivisor)

for x in range(len(divisor)):
    anotherDivisor = int(usrInput) / divisor[x]
    if float.is_integer(anotherDivisor) == True and anotherDivisor <= 9 and anotherDivisor > 0 and int(divisor[x]) > 0:
        flag.append(True)
    else:
        flag.append(False)

for n in range(len(divisor)):
    if bool(flag[n]) == True:
        finalFlag = True

if finalFlag == True:
    print("Yes")
else:
    print("No")
import sys

input = sys.stdin.readline



S = input()
T = input()

S = S.replace('\n','')
T = T.replace('\n','')

s_list = list(S)
t_list = list(T)

itti = 0
max_itti = 0
for s in s_list:
    if s == t_list[itti]:
        itti += 1
        max_itti = max(max_itti,itti)
    else:
        itti = 0
flag = False

if max_itti == 0:
    for s in s_list:
        for t in t_list:
            if s == t:
                max_itti = 1
                flag = True
            if flag:
                break
        if flag:
            break
                

print(len(t_list) - max_itti)

### FIXED CODE ###

import sys

input = sys.stdin.readline



S = input()
T = input()

S = S.replace('\n','')
T = T.replace('\n','')

s_list = list(S)
t_list = list(T)

itti = 0
min_count = 10**5
for i in range(len(s_list)):
    if i + len(t_list) > len(s_list):
        break
    count = 0
    for j in range(len(t_list)):
        if not s_list[i+j] == t_list[j]:
            count += 1
    min_count = min(count,min_count)

print(min_count)
from itertools import permutations

n = int(input())
distance_array = [[0 for x in range(2)] for y in range(n)]
for i in range(n):
    x, y = map(int, input().split())
    distance_array[i][0] = x
    dustance_array[i][1] = y
p = permutations([x for x in range(n)], 8)
print(p)
                  

### FIXED CODE ###

from itertools import permutations


def calc_distance(x1, y1, x2, y2):
    return ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5


n = int(input())
xy_array = [[int(x) for x in input().split()] for y in range(n)]
p = permutations([x for x in range(n)])

sum_distance = 0
for order in p:
    for index in range(n - 1):
        x1 = xy_array[order[index]][0]
        x2 = xy_array[order[index + 1]][0]
        y1 = xy_array[order[index]][1]
        y2 = xy_array[order[index + 1]][1]
        sum_distance += calc_distance(x1, y1, x2, y2)
tmp = 1
for i in range(2, n + 1):
    tmp *= i
print(sum_distance / tmp)
import math

r = int(input())
area = r * r * math.pi
length = r * 2 * math.pi

print("{0:.6f}".format(area),end=' ')
print("{0:.6f}".format(length))

### FIXED CODE ###

import math
r = float(input())

area = r * r * math.pi
length = r * 2 * math.pi

print("{0:.6f}".format(area),end=' ')
print("{0:.6f}".format(length))
import numpy as np

n = int(input())

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

y = np.zeros((n, 1), dtype=np.int)

for i, wa in enumerate(a):
    y[i][0] = wa

A = np.zeros((n, n), dtype=np.int)

for i in range(n-2):
    A[i][i] = 1
    A[i][i+1] = 1

A[n-1][n-1] = 1
A[n-1][0] = 1

S = np.linalg.solve(A,y)*2

for i in range(n-1):
    print(int(S[i][0]), end=" ")
print(int(S[n-1][0]))


### FIXED CODE ###

import numpy as np
import sys

n = int(input())

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

a_sum = sum(a)
# x[i]はi番目のダムに溜まった水の半分
x = []

x_0 = int(a_sum/2)

for i in range(int((n-1)/2)):
    x_0 -= a[2*i+1]

x.append(x_0)
x_tmp = x_0

for i in range(n-1):
    x_tmp = a[i] - x_tmp
    x.append(x_tmp)

for wa in x:
    print(wa*2, end=' ')
N,M = map(int,input().split())
A = [list(map(int, input().split())) for i in range(M)]
visit = set()
G = collections.defaultdict(set)
for idx,(f,to) in enumerate(A):
    G[f].add(to)

cache = {}
    
def dfs(start):
    if start in cache:
        return cache[start]
    ma = 0
    for i in G[start]:
        if i not in visit:
            visit.add(i)
            ma = max(ma,dfs(i))
            visit.remove(i)
    cache[start] = ma + 1 
    return ma + 1

ma = 0 
for f,to in A:
    visit.add(f)
    ma = max(ma,dfs(f))
    visit.remove(f)
print(ma - 1)
        
        

### FIXED CODE ###

import collections
import sys
sys.setrecursionlimit(10000000)

N,M = map(int,input().split())
A = [list(map(int, input().split())) for i in range(M)]
visit = set()
G = collections.defaultdict(set)
for idx,(f,to) in enumerate(A):
    G[f].add(to)

cache = {}
    
def dfs(start):
    if start in cache:
        return cache[start]
    ma = 0
    for i in G[start]:
        if i not in visit:
            visit.add(i)
            ma = max(ma,dfs(i))
            visit.remove(i)
    cache[start] = ma + 1 
    return ma + 1

ma = 0 
for f,to in A:
    visit.add(f)
    ma = max(ma,dfs(f))
    visit.remove(f)
print(ma - 1)
n = int(input())
s =[int(input()) for i in range(n)]
s.sort()
s_sum =sum(s)
if s_sum % 10 != 0:
  print(s_sum)
a = 1
i = 0
else:
  while a:
    if s[i] % 10 != 0:
      s[i] = 0
      a = 0
    i += 1    
  print(s_sum)

### FIXED CODE ###

n = int(input())
s = [0]
for i in range(n):
  s.append(int(input()))
m=sum(s)
s.sort()
for x in s:
  if (m-x)%10!=0:
    print(m-x)
    exit()
print(0)
def main(test_case,clear_case):
    if test_case <= clear_case:
      return "Yes"
    else:
      return "No"
    
if __name__ == "__main__":
    input_num = input()
    int(num1) = input_num.split()[0]
    int(num2) = input_num.split()[1]
    print(main(num1,num2))

### FIXED CODE ###

def main(test_case,clear_case):
    if test_case <= clear_case:
      return "Yes"
    else:
      return "No"
    
if __name__ == "__main__":
    input_num = input()
    num1 = int(input_num.split()[0])
    num2 = int(input_num.split()[1])
    print(main(num1,num2))
x,n = map(int, input().split())
if n != 0:
    p = list(map(int, input().split()))

smaller = 0
for i in range(x):
    if x - i in p:
        pass
    else:
        smaller = x-i
        break

bigger = 2*x
for j in range(x):
    if x + j in p:
        pass
    else:
        bigger = x + j
        break

ans = smaller if x - smaller <= bigger - x else bigger
#print(bigger)
print(ans)

### FIXED CODE ###

x,n = map(int, input().split())
if n != 0:
    p = list(map(int, input().split()))
    smaller = 0
    for i in range(x):
        if x - i in p:
            pass
        else:
            smaller = x-i
            break

    bigger = 2*x
    for j in range(x):
        if x + j in p:
            pass
        else:
            bigger = x + j
            break

    ans = smaller if x - smaller <= bigger - x else bigger
    #print(bigger)
    print(ans)
else:
    print(x)
inpt = input()
l = inpt.split("\n")[0]
m = inpt.split("\n")[1]

z = l.split(' ')
M = int(z[1])
N = int(z[0])
C = (1/(4*M))*N
F = m.split(' ')
X = []
print("No")

for item in F:
	votes = int(item)
	X.append(votes)
X.sort(reverse = True)
for i in range(M):
	if X[i]<C:
		print("No")
		return
print("Yes")


### FIXED CODE ###

l = input()
m = input()
z = l.split(' ')
M = int(z[1])
N = int(z[0])
F = m.split(' ')
X = []
 
for item in F:
  votes = int(item)
  X.append(votes)

S = sum(X)
C = (S/(4*M))
X.sort(reverse=True)
if X[M-1]<C:
  print("No")
else:
  print("Yes")
s=input()
ll=list(input().split())
l=[]
cnt=0
for i in range(len(s)):
  if s[i]=="?":
    c=""
    if i+1<len(s):
      if s[i+1]=="D":
        c="P"
    if i>0:
      if s[i-1]=="P":
        c="D"
    if c=="":
      c="D"
    l.append(ll[cnt])
    l.append(c)
    cnt+=1
l.append(ll[-1])
print("".join(l))

### FIXED CODE ###

s=input()
ll=list(s.split("?"))
l=[]
cnt=0
for i in range(len(s)):
  if s[i]=="?":
    c=""
    if i+1<len(s):
      if s[i+1]=="D":
        c="P"
    if i>0:
      if s[i-1]=="P":
        c="D"
    if c=="":
      c="D"
    l.append(ll[cnt])
    l.append(c)
    cnt+=1
l.append(ll[-1])
print("".join(l))
N,M = map(int, input().split())
if N==M==1:
    print(1)
elif n == 1 or m == 1:
    print(max(N,M)-2)
else:
    print((N-2) * (M-2))

### FIXED CODE ###

N,M = map(int, input().split())
if N==M==1:
    print(1)
elif N == 1 or M == 1:
    print(max(N,M)-2)
else:
    print((N-2) * (M-2))
a,b,c,d = map(int, input().split())

if b>=0 and d>= 0:
    ans = b*d
elif b < 0 and d >= 0:
    if c <= 0: ans = max(ans,0)
    else: ans = b*c
elif b >= 0 and d < 0:
    if a <= 0: ans = 0
    else: ans = a*d
else:
    ans = a*c

if a <= 0 and c <= 0:
    ans = max(ans,a*c)

print(ans)

### FIXED CODE ###

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

ans = max(a*c,a*d,b*c,b*d)
if a*b <= 0 or c*d <= 0:
    ans = max(0,ans)

print(ans)

# if b>=0 and d>= 0:
#     ans = b*d
# elif b < 0 and d >= 0:
#     if c <= 0: ans = max(ans,0)
#     else: ans = b*c
# elif b >= 0 and d < 0:
#     if a <= 0: ans = 0
#     else: ans = a*d
# else:
#     ans = a*c

# if a <= 0 and c <= 0:
#     ans = max(ans,a*c)

# print(ans)
def N(n):
	if n %1000 == 0:
		print('0')
	elif n %1000 != 0:
		return n %1000
N(n)

### FIXED CODE ###

N = int(input())

for i in range(11):
    money = i * 1000
    if money - N>=0:
        print(money - N)
        break
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

import sys
sys.setrecursionlimit(4000)

n,q = mi()
b = [[] for i in range(n)]
ans = [0]*n
for i in range(n-1):
    a,c = mi()
    b[a-1].append(c-1)
    b[c-1].append(a-1)


def chil_pop(l):
    for i in b[l]:
        b[i].pop(b[i].index(l))
        chil_pop(i)

chil_pop(0)

def chil_add(z,x):
    ans[z] += x
    for i in b[z]:
        chil_add(i,x)

for i in range(q):
    p,x = mi()
    chil_add(p-1,x)

for i in range(n):
    print(ans[i],end=' ')


### FIXED CODE ###

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

import sys
sys.setrecursionlimit(40000000)

n,q = mi()
b = [[] for i in range(n)]
ans = [0]*n

# O(2n)
for i in range(n-1):
    a,c = mi()
    b[a-1].append(c-1)
    b[c-1].append(a-1)

# jun = []
# O(2n)
# def chil_pop(l,p):
#     jun.append(l)
#     for i in b[l]:
#         if i == p:
#             continue
#         chil_pop(i,l)
#     b[l] = p

# chil_pop(0,-1)


# O(q)
for i in range(q):
    p,x = mi()
    ans[p-1] += x


count = 0
q = [(0,-1)]
while q:
    c,p = q.pop()
    for i in b[c]:
        if i == p:
            continue
        ans[i] += ans[c]
        q.append((i,c))
    
    

# for i in jun[1:]:
#     ans[i] += ans[b[i]]

# ans_str = ''
# for i in range(n):
#     print(ans[i],end=' ')
#     # ans_str = ans_str + str(ans[i]) + ' '
print(*ans)
N, W = map(int, input().split())
w, v = [0] * N, [0] * N
for i in range(N):
	w[i], v[i] = map(int, input().split())

dp = [[0] * (W + 1) for _ in range(N + 1)]
# dp[i][j](j=0,1,...,W)の値が求まっている状態で、dp[i+1][j]を更新することを考える

for i in range(N):
    for j in range(W+1):#重さ0からWまでチェック
        if j-w[i]>=0:#入れてもOKな場合,容量と価値を足す
            dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i])
        else:#何も入れずに先に進む
            dp[i+1][j]=dp[i][j]
print(max(set(dp))


### FIXED CODE ###

N, W = map(int, input().split())
w, v = [0] * N, [0] * N
for i in range(N):
	w[i], v[i] = map(int, input().split())

dp = [[0] * (W + 1) for _ in range(N + 1)]
# dp[i][j](j=0,1,...,W)の値が求まっている状態で、dp[i+1][j]を更新することを考える

for i in range(N):
    for j in range(W+1):#重さ0からWまでチェック
        if j-w[i]>=0:#入れてもOKな場合,容量と価値を足す
            dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i])
        else:#何も入れずに先に進む
            dp[i+1][j]=dp[i][j]
print(dp[N][W])
a,b = map(int,input())
 
if a <= 5:
	print("0")
        
elif a <= 12:
	print(b/2)
        
else:
	print(b)
	

### FIXED CODE ###

a,b = map(int,input().split())
 
if a <= 5:
	print(0)
        
elif a <= 12:
	print(int(b/2))
        
else:
	print(b)
a, b, c= map(int, input().split())
kawaiso = 0 
if a==b && a!=c:
    kawaiso = 1

if b==c && b!=a :
    kawaiso = 1

if c==a && c!=b :
    kawaiso = 1
else :
    kawaiso = 0
    
if kawaiso == 1 :
    print ('yes')

else :
    print('No')


### FIXED CODE ###

a, b, c= map(int, input().split())
kawaiso = 0 
if a==b and a!=c:
    kawaiso = 1
 
elif  b==c and b!=a:
    kawaiso = 1
 
elif c==a and c!=b:
    kawaiso = 1
    
else:
    kawaiso = 0
  
 
if kawaiso == 1:
    print ("Yes")
    
else:
    print("No")
a,b,c=map(int,input().split())
S=[a,b,c]
print(S.count(1))

### FIXED CODE ###

s=list(input())
count=0
if s[0]=="1":
    count+=1
if s[1]=="1":
    count+=1
if s[2]=="1":
    count+=1
print(count)
def func(N):
    tmp=N
    arr=[]
    for i in range(2,int(-(-N**0.5//1))+1):
        if tmp%i==0:
            cnt=0
            while tmp%i==0:
                cnt+=1
                tmp//=i
            arr.append([i,cnt])
            
    if temp!=1:
        arr.append([tmp, 1])
    if arr==[]:
        arr.append([n,1])
   
    return arr

N=int(input())
a=func(N)
ans=0
if a[0][0]==1:
        print(0)
        exit()
        
b=[1,3,6,10,15,21,28,36,45]
for i in a:
    for j in range(len(b)):
       if  i[1]<b[j]:
          ans+=j
          break
print(ans)
    
            

### FIXED CODE ###

def func(N):
    tmp=N
    arr=[]
    for i in range(2,int(-(-N**0.5//1))+1):
        if tmp%i==0:
            cnt=0
            while tmp%i==0:
                cnt+=1
                tmp//=i
            arr.append([i,cnt])
            
    if tmp!=1:
        arr.append([tmp, 1])
    if arr==[]:
        arr.append([tmp,1])
   
    return arr

N=int(input())
a=func(N)
ans=0
if a[0][0]==1:
        print(0)
        exit()
        
b=[1,3,6,10,15,21,28,36,45]
for i in a:
    for j in range(len(b)):
       if  i[1]<b[j]:
          ans+=j
          break
print(ans)
a,b,c=map(int,input().split())
if a+b==c || a+c==b || b+c==a:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

a,b,c=map(int,input().split())
if a+b==c or a+c==b or b+c==a:
  print("Yes")
else:
  print("No")
N = int(input())
s = str(len(N))
 
if s = 1 :
	print(N)
elif s = 2 :
	print(9)
elif s = 3 :
	print(9 + N -99)
elif s = 4 :
	print(909)
elif s = 5 :
	print(909 + N - 9999)
elif s = 6 :
	print(90909)

### FIXED CODE ###

n = int(input())
 
if  n <= 9:
    print(n)
elif 10 <= n <= 99:
    print(9)
elif 100 <= n <= 999:
    print(n-99+9)
elif 1000 <= n <= 9999:
    print(909)
elif 10000 <= n <= 99999:
    print(n-9999+909)
elif n == 100000:
    print(90909)
n = int(input())
a = list(map(int,input().split()))
b = [0]*n
for i in range(n):
    b[i]= i-a[0]-a[i]
d = defaultdict(int)
for i in range(1,n):
    d[b[i]] += 1
ans = 0
x = 0
for i in range(n-1):
    ans+=d[x]
    d[b[i+1]]-=1
    x -= -1+(a[i]-a[i+1])
print(ans)

### FIXED CODE ###

from collections import defaultdict
n = int(input())
a = list(map(int,input().split()))
b = [0]*n
for i in range(n):
    b[i]= i-a[0]-a[i]
d = defaultdict(int)
for i in range(1,n):
    d[b[i]] += 1
ans = 0
x = 0
for i in range(n-1):
    ans+=d[x]
    d[b[i+1]]-=1
    x -= -1+(a[i]-a[i+1])
print(ans)
import sys


def main():
    n, m = map(int, input().split())
    g = [[] for i in range(n)]
    lines = sys.stdin.read().splitlines()
    for i in range(m):
        l, r, d = map(int, lines[i].split())
        g[l - 1].append((r - 1, d))
        g[r - 1].append((l - 1, -d))
    dis = [0] * n
    visited = [False] * n
    for i in range(n):
        if visited[i]:
            continue
        stack = list([i])
        visited[i] = True
        while len(stack):
            v = stack[-1]
            stack.pop()
            for u, d in g[v]:
                if not visited[u]:
                    dis[u] = dis[v] + d
                    stack.append(u)
                    visited[u] = True
    for v in range(n):
        for u, d in g[v]:
            if dis[v] + d != dis[u]:
                print('No')
                return
    print('Yes')


if __name__ == '__main__':
    main()


### FIXED CODE ###

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

print((x - a) % b)
flag = False
while True:
    try:
        string = [input() for _ in range(8)]
    except:
        break
    if flag:
        print()
    string = [int(l) for line in string for l in line] + [0]*16
    one = string.index(1)
    s = string[one:]
    ones = [[1, 8, 9], [8, 16, 24], [1, 2, 3],
            [7, 8, 15], [1, 9, 10], [8, 9, 17], [1, 7, 8]]
    ans = {0: "A", 1: "B", 2: "C", 3: "D", 4: "E", 5: "F", 6: "G"}
    for k, o in enumerate(ones):
        if all([s[o[0]], s[o[1]], s[o[2]]]):
            print(ans[k])
    flag = True

### FIXED CODE ###

while True:
    try:
        string = [input() for _ in range(8)]
        string = [int(l) for line in string for l in line] + [0]*32
        one = string.index(1)
        s = string[one:]
        ones = [[1, 8, 9], [8, 16, 24], [1, 2, 3],
                [7, 8, 15], [1, 9, 10], [8, 9, 17], [1, 7, 8]]
        ans = {0: "A", 1: "B", 2: "C", 3: "D", 4: "E", 5: "F", 6: "G"}
        for k, o in enumerate(ones):
            if all([s[o[0]], s[o[1]], s[o[2]]]):
                print(ans[k])
        input()
    except:
        break
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(a[k+1])

### FIXED CODE ###

a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(a[k-1])
import bisect
import numpy as np
N,M,Q = map(int,input().split())
lr = [0]*M
for i in range(M):
    l,r = map(int,input().split())
    lr[i] = [l,r]
lr = sorted(lr,key=lambda x:x[0])
lr_t = list(np.array(lr).transpose())
index_dict={}
r_dict={} 
d = {}
for i in range(N):
    index_dict[i+1]=bisect.bisect_left(lr_t[0],i+1)
    r_dict[i+1]=sorted(lr_t[1][index_dict[i+1]:])
for i in range(Q):
    p,q = map(int,input().split())
    if p not in d:
        d[p]={}
        I = index_dict[p]
        r = r_dict[p]
        I = bisect.bisect(r,q)
        print(I)
        d[p][q]=I
    else:
        if q not in d[p]:
            I = index_dict[p]
            r = r_dict[p]
            I = bisect.bisect(r,q)
            print(I)
            d[p][q]=I
        else:
            print(d[p][q])


### FIXED CODE ###

import numpy as np
N,M,Q = map(int,input().split())
c = [[0]*(N+1) for i in range(N+1)]
for i in range(M):
    l,r = map(int,input().split())
    c[l][r] += 1
c = np.cumsum(np.cumsum(c,axis=0),axis=1)
for i in range(Q):
    p,q = map(int,input().split())
    print(c[q][q]-c[q][p-1]-c[p-1][q]+c[p-1][p-1])
N = int(input())

ans = int(N(N-1)/2)
print(ans)

### FIXED CODE ###

N = int(input())

ans = (N * (N-1) // 2)
print(ans)
n = input()

s = N % 10

if s in [3]
	print('bon')
if s in [0, 1, 6, 8]
	print('hon')
if s in [2, 4, 5, 7, 9]
    print('pon')

### FIXED CODE ###

N = input()
s = int(N) % 10
if s == 3:
    print('bon')
if s == 0:
    print('pon')
if s == 1:
    print('pon')
if s == 6:
    print('pon')
if s == 8:
    print('pon')

if s == 2:
    print('hon')
if s == 4:
    print('hon')
if s == 5:
    print('hon')
if s == 7:
    print('hon')
if s == 9:
    print('hon')