Harryxun/stf_run huggingface dataset:
def main():
    import sys
    from collections import deque
    input = sys.stdin.readline
    N = int(input())
    color = [-1] * N
    color[0] = 0
    uvw = []
    edge = [[]for _ in range(N)]
    # append=uvw.append
    for i in range(N-1):
        ui, vi, wi = map(int, input().split())
        ui -= 1
        vi -= 1
        edge[ui].append((vi, wi))
        edge[vi].append((ui, wi))
    stack = [0]
    for i in range(N):
        tmp = deque()
        while stack:
            i = stack.pop()
            for e, w in edge[i]:
                if color[e] == -1:
                    stack.append(e)
                    if color[i] == 0:
                        if w % 2 == 0:
                            color[e] = 0
                        else:
                            color[e] = 1
                    else:
                        if w % 2 == 0:
                            color[e] = 1
                        else:
                            color[e] = 0
                # ここを追加--------------------------------------
                # 矛盾判定
                else:
                    if (color[i] == color[e]) != (x % 2 == 0):
                        print(-1)
                        exit()
                # ^^^^^^^^--------------------------------------
        # print(color)
        stack = tmp
    print(*color, sep="\n")


if __name__ == '__main__':
    main()


### FIXED CODE ###

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.nodes = [-1] * n  # nodes[x]: 負なら、絶対値が木の要素数

    def get_root(self, x):
        # nodes[x]が負ならxが根
        if self.nodes[x] < 0:
            return x
        # 根に直接つなぎ直しつつ、親を再帰的に探す
        else:
            self.nodes[x] = self.get_root(self.nodes[x])
            return self.nodes[x]

    def unite(self, x, y):
        root_x = self.get_root(x)
        root_y = self.get_root(y)
        # 根が同じなら変わらない
        # if root_x == root_y:
        # pass
        if root_x != root_y:
            # 大きい木の方につないだほうが計算量が減る
            if self.nodes[root_x] < self.nodes[root_y]:
                big_root = root_x
                small_root = root_y
            else:
                small_root = root_x
                big_root = root_y
            self.nodes[big_root] += self.nodes[small_root]
            self.nodes[small_root] = big_root


N, M = map(int, input().split())
uf = UnionFind(N)
get_root, unite, nodes = uf.get_root, uf.unite, uf.nodes

for _ in range(M):
    x, y, _ = map(int, input().split())
    x -= 1
    y -= 1
    unite(x, y)
ans = 0
for i in range(N):
    if nodes[i] < 0:
        ans += 1
print(ans)
import math

n,m=map(int,input().split())

if n==m-1 or n==m+1:
  print((math.factorial(m)*math.factorail(n))%(1e9+7))
elif n==m:
  print((2*(math.factorial(m)**2))%(1e9+7))
else:
  print(0)


### FIXED CODE ###

import math

n,m=map(int,input().split())

if n==m+1 or n==m-1:
    print((math.factorial(m)*math.factorial(n))%(10**9+7))
elif n==m:
    print((2*(math.factorial(m)**2))%(10**9+7))
else:
    print(0)
import math

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

S = input().split()

A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])

CD = lcm(C, D)

count_B = B - (B // C) - (B // D) + (B // CD)
count_A = A - 1 - ((A - 1) // C) - ((A - 1) // D) + ((A - 1) // CD)

print(count_B - count_A)

### FIXED CODE ###

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
    
S = input().split()

A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])

CD = (C * D) // gcd(C, D)

count_B = B - (B // C) - (B // D) + (B // CD)
count_A = A - 1 - ((A - 1) // C) - ((A - 1) // D) + ((A - 1) // CD)

print(count_B - count_A)
from collections import Counter
#Nをセットする
N = int(input())
#aiをセットする
a = list(map(int,input().split()))
a_mai = []
a_pura = []
#ai +- 1したものを作る
for i in range(len(a)):
    #+1したもの
    a_pura.append(a[i] + 1)
    #-1したもの
    a_mai.append(a[i] - 1)
#aiそのままの重複の数
count_a = Counter(a)
#ai + 1重複の数
count_a_pura = Counter(a_pura)
#ai - 1の中腹の数
counter_a_mai = Counter(a_mai)
#一番大きい要素を取得
max_a = count_a.most_common()[0][1]
max_a_pura = count_a_pura.most_common()[0][1]
max_a_mai = counter_a_mai.most_common()[0][1]

#3つの最大値を求める
max = max_a
if max_a_pura >= max:
    max = max_a_pura
if max_a_mai >= max:
    max = max_a_mai
print(max)

### FIXED CODE ###

#砂時計の砂X(秒)をセット #測った時間tをセット
X , t = map(int,input().split())
#残り時間を表示 (X - t)
#X > tのとき
if X > t:
    time = X - t
#X <= tのとき
else:
    time = 0
print(time)
import math
from functools import reduce

n,x = map(int, input().split())
X = [int(i) for i in input().split()]
X = [abs(x-j) for j in X]
ans = reduce(math.gcd, X)
print(ans)

### FIXED CODE ###

from fractions import gcd
from functools import reduce

n,x = map(int, input().split())
X = [int(i) for i in input().split()]
X = [abs(x-j) for j in X]
ans = reduce(gcd, X)
print(ans)
import re
import numpy as np
 
W, H, x, y = [int(i) for i  in re.split(" ", input())]
 
print(W * H / 2)
 
if x * 2 == W and y * 2 == H:
  print(1)
else:
  print(0)

### FIXED CODE ###

import re
X, A = [int(i) for i in re.split(" ", input())]
if X < A:
  print(0)
else:
  print(10)
N = int(input())
import math 

start = int(math.sqrt(N))+1
for i in range(start,0,-1):
    if N%i==0:
        print(i+N//i-2)
        break

### FIXED CODE ###

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

import math 

if x>= a**2*b/2:
    tan = 2*(b/a-x/(a**3))
    y = math.atan(tan)
else :
    tan = a*(b**2)/(2*x)
    y = math.atan(tan)

print(math.degrees(y))
h,*b,t = input()
print(h+str(len(b))+t

### FIXED CODE ###

# %% A
h,*b,t = input()
print(h+str(len(b))+t)
def solver(s, k):
    res = 0
    
    for i in range(1, len(s)):
        if s[i] == s[i - 1]:
            s[i] = 'A'
            res += k
    
    if s[0] == s[-1]:
        res += k - 1
        if s[0] == s[1]:
            res -= 1
    
    return res

# def solver2(s, k):
    t = []
    for _ in range(k):
        t += s
    res = 0
    for i in range(1, len(t)):
        if t[i] == t[i - 1]:
            t[i] = 'A'
            res += 1
    return res, t

s = list(input())
k = int(input())

# ss = s[:]
# kk = k
print(solver(s, k))
# print(solver2(ss, kk))


### FIXED CODE ###

def solver(s, k):
    res = 0
    cnt = [1]
    for i in range(1, len(s)):
        if s[i] == s[i - 1]:
            cnt[-1] += 1
        else:
            cnt.append(1)
    for x in cnt:
        res += (x // 2) * k

    if len(cnt) == 1: #全部同じ場合はここでおわり
        return (len(s) * k) // 2

    if s[0] == s[-1]:
        res -= (cnt[0] // 2) * (k - 1) + (cnt[-1] // 2) * (k - 1)
        res += ((cnt[0] + cnt[-1]) // 2) * (k - 1)
    return res

def solver2(s, k):
    t = []
    for _ in range(k):
        t += s
    res = 0
    cnt = 1
    for i in range(1, len(t)):
        if t[i] == t[i - 1]:
            cnt += 1
        else:
            res += cnt // 2
            cnt = 1
    res += cnt // 2
    return res

s = input()
k = int(input())

#ss = s
#kk = k
print(solver(s, k))
#print(solver2(ss, kk))

#　ランダムな英小文字列の生成
import random
import string

# n := 文字列の長さ
def randomCharacter(n):
   alphabet_m = string.ascii_lowercase
   return ''.join([random.choice(alphabet_m) for _ in range(n)])


#for i in range(40):
#    if i == 0:
#        st = 'aaaaaaaaa'
#    elif i == 1:
#        st = 'a'
#    else:
#        l = random.randrange(1, 10)
#        st = randomCharacter(l)
#    sstt = st
#    cnt = 4
#    cnst_st = st[:]
#    res1 = solver(st, cnt)
#    res2 = solver2(sstt, cnt)
#    if res1 == res2:        
#        print("OK!")
#    else:
#        print(''.join(cnst_st), res1, res2)
l, n = map(int, input().split())

st = []
for _ in range(n):
  st.append(str(input()))

st.sort()
ans = ''

for s in st:
  ans += s
  
print(ans)


### FIXED CODE ###

N, L = map(int, input().split())
list=[]
for i in range(N):
    list.append(str(input()))
list.sort()
print("".join(list))
S=input()
Wether=[Sunny,Cloudy,Rainy]
if S==Wether[0]:
    print(Wether[1])
elif S==Wether[1]:
    print(Wether[2])
elif S==Wether[2]:
    print(Wether[0])

### FIXED CODE ###

S=input()
Wether=["Sunny","Cloudy","Rainy"]
if S==Wether[0]:
    print(Wether[1])
elif S==Wether[1]:
    print(Wether[2])
elif S==Wether[2]:
    print(Wether[0])
N = int(input())
A = list(map(int,input().split()))

hai = 0
tya = 0
mizu = 0
ao = 0
ki = 0
dai = 0
aka = 0
mu = 0

for a in A:
  if a <= 399:
    hai = 1
  elif a <= 799:
    tya = 1
  elif a <= 1199:
    mizu = 1
  elif a <= 1599:
    ao = 1
  elif a <= 1999:
    ki = 1
  elif a <= 2399:
    dai = 1
  elif a <= 3199:
    aka = 1
  else:
    mu += 1
    
max_num = min(8, hai + tya + mizu + ao + ki + dai + aka + mu)
min_num = max(hai + tya + mizu + ao + ki + dai + aka)

print(min_num, max_num)

### FIXED CODE ###

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

color = [0] * 9

for a in A:
  if a <= 399:
    color[0] = 1
  elif a <= 799:
    color[1] = 1
  elif a <= 1199:
    color[2] = 1
  elif a <= 1599:
    color[3] = 1
  elif a <= 1999:
    color[4] = 1
  elif a <= 2399:
    color[5] = 1
  elif a <= 2799:
    color[6] = 1
  elif a <= 3199:
    color[7] = 1
  else:
    color[8] += 1
    
max_num = sum(color)
min_num = max(1, sum(color[:-1]))
 
print(min_num, max_num)
n, k = map(int,input().split())
h = []
for i in range(n):
	h.append(int(input()))
h.sort()

ans_l = []
for i in range(n-k+1):
	ans_l.append(ans_l[i+k-1] - ans_l[i])
print(min(ans_l))

### FIXED CODE ###

n,k=map(int,input().split())
h=list(int(input())for _ in range(n))
h.sort()
l=[]
for i in range(n-k+1):
    l.append(h[k+i-1]-h[i])


print(min(l))
n=int(input())
s=input()
cnt=0
if len(s)<= 2:
  pass
else:
  for i in range(len(s)):
    if s[i]=='A' and s[i+1]=='B' and s[i+2]=='C':
      cnt += 1
print(cnt)

### FIXED CODE ###

n=int(input())
s=input()
cnt=0
if len(s)<= 2:
  pass
else:
  for i in range(len(s)-2):
    if s[i]=='A' and s[i+1]=='B' and s[i+2]=='C':
      cnt += 1
print(cnt)
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect


def lcm(a, b):
    """最小公倍数"""
    from math import gcd
    return (a * b) // gcd(a, b)


# from decorator import stop_watch
# 
# 
# @stop_watch
def solve(A, B):
    print(lcm(A, B))


if __name__ == '__main__':
    A, B = map(int, input().split())
    solve(A, B)


### FIXED CODE ###

# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect


def gcd(a, b):
    """最大公約数"""
    a, b = (a, b) if a >= b else (b, a)
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    """最小公倍数"""
    # from math import gcd
    return (a * b) // gcd(a, b)


# from decorator import stop_watch
#
#
# @stop_watch
def solve(A, B):
    print(lcm(A, B))


if __name__ == '__main__':
    A, B = map(int, input().split())
    solve(A, B)
a,b = list(map(int,input().split()))
if a * b % 2 = 0:
  print(a * b / 2)
else:
  print(a * b // 2)

### FIXED CODE ###

a,b = list(map(int,input().split()))
if a == 1 or b == 1:
  print(1)
elif a * b % 2 == 0:
  print(a * b // 2)
else:
  print(a * b // 2 + 1)
n=int(input())
a=int(input())
print('Yes' if n%500<==a else 'No')

### FIXED CODE ###

n=int(input())
a=int(input())
print('Yes' if n%500<=a else 'No')
x = int(input())
u = 0

def b(x,u):
    if x>5:
        x-=5
        u+=5
        b(x,u)
    else:
        print(u)

def a(x,u):
    if x>500:
        x-=500
        u+=1000
        a(x,u)
    else:
        b(x,u)

a(x,u)

### FIXED CODE ###

x = int(input())
u = 0
def a(x,u):
    if x>=500:
        u+=1000 * (x // 500)
        x = x % 500
        a(x,u)
    elif x>=5:
        u+=5 * (x // 5)
        x = x % 5
        a(x,u)
    else:
        print(u)
a(x,u)
# from math import gcd
from fraction import gcd

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


N, M = map(int, input().split())
S = input()
T = input()

if N > M:
  N, M = M, N
  S, T = T, S

i = 0

while True:
  i += 1
  L = i*lcm(N, M)
  N_list = [(L//N)*k + 1 for k in range(N)]
  M_list = [(L//M)*k + 1 for k in range(M)]

  memo = {}

  for idx, n in enumerate(N_list):
    memo[n] = S[idx]

  for idx, m in enumerate(M_list):
    if m in memo.keys():
      if memo[m] != T[idx]:
        break
  else:
    print(L)
    exit(0)

  if L == N*M:
    break

print(-1)


### FIXED CODE ###

# from math import gcd
from fractions import gcd

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


N, M = map(int, input().split())
S = input()
T = input()

if N > M:
  N, M = M, N
  S, T = T, S

i = 0

while True:
  i += 1
  L = i*lcm(N, M)
  N_list = [(L//N)*k + 1 for k in range(N)]
  M_list = [(L//M)*k + 1 for k in range(M)]

  # print(N_list)
  # print(M_list)

  memo = {}

  for idx, n in enumerate(N_list):
    memo[n] = S[idx]

  for idx, m in enumerate(M_list):
    if m in memo.keys():
      if memo[m] != T[idx]:
        break
  else:
    print(L)
    exit(0)

  # if L == N*M:
  break

print(-1)
import functools
n,k=int(input())
p=list(map(int,input().split()))
p.sort()
cost=functools.reduce(lambda x,y:x+y,p[:k],0)
print(cost)

### FIXED CODE ###

import functools
n,k=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
cost=functools.reduce(lambda x,y:x+y,p[:k],0)
print(cost)
n, m = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
k = []
for i in l:
  if(i >= sum(l)/(4*m)):
    k.append(i)
if(len(k) < m):
  print("No")
else:
print("Yes")

### FIXED CODE ###

n, m = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
k = []
for i in l:
  if(i >= sum(l)/(4*m)):
    k.append(i)
if(len(k) < m):
  print("No")
else:
  print("Yes")
n=int(input())
p=(0,0)
now=0
for _ in range(2):
    t,x,y=map(int,input().split())
    mov=abs(x-p[0])+abs(y-p[1])
    if t-now<mov or (t-now-mov)%2==1:
        print("No")
        break
else:print("Yes")

### FIXED CODE ###

n=int(input())
p=(0,0)
now=0
for _ in range(n):
    t,x,y=map(int,input().split())
    mov=abs(x-p[0])+abs(y-p[1])
    if t-now<mov or (t-now-mov)%2==1:
        print("No")
        break
    p=(x,y)
    now=t
else:print("Yes")
x, y  = map(int, input().split)
print(x * y)

### FIXED CODE ###

x, y  = map(int, input().split())
print(x * y)
import copy
N=int(input())
li = list(map(int,input().split()))
for i in range(0,N):
	li[i] = li[i] - i -1
a = []
d = copy.copy(li)
while len(d) >= 3:
	del d[max(d)]
	del d[min(d)]
for i in range(min(d),max(d)+1):
	k = 0
	for j in range(N):
		k = k + abs(li[j]-i)
	a.append(k)
print(a)

### FIXED CODE ###

n = int(input())
a = [int(i) for i in input().split()]
for i in range(0,len(a)):
    a[i] -= (i+1)
a.sort()
b = [ abs(x  - (a[n//2])) for x in a]
print(sum(b))
import sys

sys.setrecursionlimit(10 ** 9)

n, q = map(int, input().split())
root = [[] for _ in range(n)]
ans = [0 for _ in range(n)]
for _ in range(n - 1):
    a, b = map(int, input().split())
    root[a - 1].append(b - 1)
    root[b - 1].append(a - 1)
for _ in range(q):
    p, x = map(int, input().split())
    ans[p - 1] += x
    
def dfs(pos, before):
    for next_pos in root[pos]:
        if next_pos == before:
            continue
        ans[next_pos] += ans[pos]
        dfs(next_pos, pos)

dfs(0, -1)

for i in range(n):
    print(ans[i], end=" ")import sys

sys.setrecursionlimit(10 ** 9)

n, q = map(int, input().split())
root = [[] for _ in range(n)]
ans = [0 for _ in range(n)]
for _ in range(n - 1):
    a, b = map(int, input().split())
    root[a - 1].append(b - 1)
    root[b - 1].append(a - 1)
for _ in range(q):
    p, x = map(int, input().split())
    ans[p - 1] += x
    
def dfs(pos, before):
    for next_pos in root[pos]:
        if next_pos == before:
            continue
        ans[next_pos] += ans[pos]
        dfs(next_pos, pos)

dfs(0, -1)

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

### FIXED CODE ###

from sys import setrecursionlimit, stdin

setrecursionlimit(10 ** 9)

def input():
    return stdin.readline()

n, q = map(int, input().split())
root = [[] for _ in range(n)]
ans = [0 for _ in range(n)]
for _ in range(n - 1):
    a, b = map(int, input().split())
    root[a - 1].append(b - 1)
    root[b - 1].append(a - 1)
for _ in range(q):
    p, x = map(int, input().split())
    ans[p - 1] += x
    
def dfs(pos, before):
    for next_pos in root[pos]:
        if next_pos == before:
            continue
        ans[next_pos] += ans[pos]
        dfs(next_pos, pos)

dfs(0, -1)

for i in range(n):
    print(ans[i], end=" ")
def main():
    N  = int(input()) 
    A=list(map(int, input().split()))
    B = list(set(A))
    _ ,s = sieve(10**6+5)
    B.sort(reverse=True)
    cnt = 0

    if A.count(1)>1:
        print(0)
    elif A.count(1)==1:
        print(1)


    for i in range(len(B)):
        if A.count(B[i])>1:
            continue
        if s[B[i]]==False:
            cnt += 1
            continue

        Flag = True
        for j in range(i+1,len(B)):
            if B[i] % B[j] == 0:
                Flag = False
                break
        if Flag:
            cnt += 1
    
    print(cnt)


def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i
    table = [ i for i in range(1, n+1) if is_prime[i-1]]
    return is_prime, table



if __name__ == '__main__':
    main()

### FIXED CODE ###

import collections

def main():
    N  = int(input()) 
    A=list(map(int, input().split()))
    C = collections.Counter(A)
    B = list(set(A))
    B.sort()
    lenb = len(B)
    Boo = [True]*lenb
    ZENBU = [False]*(10**6+4)

    if C[1]>1:
        print(0)
        return
    if C[1]==1:
        print(1)
        return

    for i in range(lenb):
        temp = 2
        if ZENBU[B[i]]==False:
            while B[i]*temp < 1000002:
                ZENBU[B[i]*temp] = True
                temp+=1

    cnt = 0
    for i in range(lenb):
        if ZENBU[B[i]]==False and C[B[i]]==1:
            cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()
a=[0]*10000
b=[0]*10000
ct=0
a_scores=[]
b_scores=[]
while True:
    a_score=0
    b_score=0
    n=input()
    if n==0:
        break
    else :
        for i in xrange(n):
            a[ct+i],b[ct+i]=map(int,raw_input().split())
            if a[ct+i]>b[ct+i]:
                a_score+=a[ct+i]+b[ct+i]
            elif a[ct+i]==b[ct+i]:
                a_score+=a[ct+i]
                b_score+=b[ct+i]
            else:
                b_score+=b[ct+i]+a[ct+i]
        print a_score,b_score
        ct+=n

### FIXED CODE ###

while 1:
    n=input()
    if n==0:break
    ascore=0
    bscore=0
    for i in xrange(n):
        a,b=map(int,raw_input().split())
        if a>b:
            ascore+=a+b
        elif a==b:
            ascore+=a
            bscore+=b
        else:
            bscore+=a+b
    print ascore,bscore
h,w=map(int,input())
grid=[None]*h
INF=10**6
stack=[]
for i in range(h):
  s=list(input())
  for j in range(len(s)):
    if s[j]=="#":
      stack.append([i,j,0])
    s[j]=INF
  grid[i]=s
      
while stack:
  v=stack.pop()
  y=v[0]
  x=v[1]
  p=v[2]
  if p<grid[y][x]:
    grid[y][x]=p
  else:
    continue
  if y-1>=0:
    stack.append([y-1,x,p+1])
  if y+1<h:
    stack.append([y+1,x,p+1])
  if x-1>=0:
    stack.append([y,x-1,p+1])
  if x+1<w:
    stack.append([y,x+1,p+1])
    
ans=0
for i in range(len(grid)):
  ans=max(ans,max(grid[i]))
print(ans)

### FIXED CODE ###

H,W=map(int,input().split())
INF=10**4
import numpy as np
a=np.full((H,W),INF,dtype=int)
for i in range(H):
  s=input()
  for j in range(len(s)):
    if s[j]=="#":
      a[i,j]=0

for i in range(0,W-1):
  np.minimum(a[:,i]+1,a[:,i+1],out=a[:,i+1])
for i in range(W-1,0,-1):
  np.minimum(a[:,i]+1,a[:,i-1],out=a[:,i-1])
for j in range(0,H-1):
  np.minimum(a[j,]+1,a[j+1,],out=a[j+1,])
for j in range(H-1,0,-1):
  np.minimum(a[j,]+1,a[j-1,],out=a[j-1,])

print(a.max())
n=input()
a=input()
b=input()
c=input()
tim = 0
for i in range(n):
    if a[i] == b[i] and b[i] != c[i]:
        tim+=1
    elif b[i] == c[i] and c[i] != a[i]:
        tim+=1
    elif c[i] == a[i] and a[i] != b[i]:
        tim+=1
    elif c[i] == a[i] and a[i] == b[i]:
        tim+=0
    else:
        tim+=2
print(tim)

### FIXED CODE ###

n,a,b = (int(i) for i in input().split())
x=min(a,b)
y=a+b-n
if y < 0:
    y=0
print(x,y)
import numpy as np
a = [list(input()) for i in range(3)]
a = np.ravel(a)
n = int(input())
b = [input() for i in range(n)]
ans = 'No'
for i in range(3):
    if b == a[i*3:i*3+2] or b == a[i:i+6:3] or b == a[0:8:4] or b == a[2:6:2]:
        ans = 'Yes'
print(ans)

### FIXED CODE ###

# ABC157 B
import numpy as np
a = [[input().split() for l in range(3)]]
a = np.ravel(a)
n = int(input())
b = [input() for i in range(n)]
ans = 'No'

def check(a,b):
    return set(a).issubset(b)

for i in range(3):
    if check(a[i*3:(i*3)+3],b) or check(a[i:i+7:3],b) or check(a[0:9:4],b) or check(a[2:7:2],b):
        ans = 'Yes'

print(ans)
a,b = map(int,input())
if a<=9 and b<=9:
    print(a*b)
else:
    print(-1)

### FIXED CODE ###

a,b = map(int,input().split())
if a<=9 and b<=9:
    print(a*b)
else:
    print(-1)
N=int(input())
A=list(map(int,input().split()))
mod=10**9+7
S=0
M=0
for i in A:
    S+=i
for i in A:
    S-=i
    M+=(S*i)%mod
print(M%mod)

### FIXED CODE ###

D,T,S=map(int,input().split())
if T>=D/S:
    print("Yes")
else:
    print("No")
h,w,n,*A=map(int,open(x:=0).read().split());c=[]
for i in range(n):c+=[i+1]*A[i]
for i in range(h):print(*(c[i*w:-~i*w])[::x]);x^=1

### FIXED CODE ###

h,w,n,*A=map(int,open(0).read().split());c=[]
for i in range(1,n+1):c+=[i]*A[i-1]
for i in range(h):print(*(c[i*w:-~i*w])[::(-1)**i])
a,b,c = map(int, input().split())
if a=b+c or b=a+c or c=a+b:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

a,b,c = sorted(map(int, input().split()))
if a+b==c:
    print("Yes")
else:
    print("No")
coin = int(input())
    fivet_yen = 0
    five_yen = 0
    if coin == 0:
        print(0)
    else:
    while(coin > 0):
        if coin >= 500:
            coin = coin - 500
            fivet_yen = fivet_yen + 1000
        else:
            if coin >= 5:
                coin = coin - 5
                five_yen   = five_yen + 5
            else:    
                coin = coin - 1


    print(fivet_yen + five_yen)
        
        
        

### FIXED CODE ###

coin = int(input())
fivet_yen = 0
five_yen = 0
if coin == 0:
    print(0)
else:
   while(coin > 0):
    if coin >= 500:
        coin = coin - 500
        fivet_yen = fivet_yen + 1000
    else:
        if coin >= 5:
            coin = coin - 5
            five_yen   = five_yen + 5
        else:  
            coin = coin - 1
   print(fivet_yen + five_yen)
N,A,B,C,D = map(int,input().split())
S = input()
M = max(C,D)
C = S
S = S[A-1:M]

for i in range(len(S) - 1):
    if S[i] == S[i+1] and S[i+1] == '#':
        print("No")
        quit()
S = C[B:M]
for i in range(len(S) - 2):
    if S[i] == S[i+1] and S[i+1]== S[i+2]  and S[i+2] == '.':
        print("Yes")
        quit()
if C <= B:
    print("Yes")
elif  C < D:
    print("Yes")
elif D <= C:
    print("No")


### FIXED CODE ###

N,A,B,C,D = map(int,input().split())
S = input()
M = max(C,D)
A -= 1
B -= 1
C -= 1
D -= 1


for i in range(A,max(C,D)):
    if S[i] == S[i+1] and S[i+1] == '#':
        print("No")
        quit()
if  C < D:
    print("Yes")
elif D <= C:
    for i in range(B-1,D):
        if S[i] == S[i+1] and S[i+1]== S[i+2]  and S[i+2] == '.':
            print("Yes")
            quit()
    print("No")
import numpy as np
S = np.array(list(map(str, input().rstrip())))
K = int(input())

for i, s in enumerate(S):
    if s != "1":
        cnt = i+1
        ans = s
        break

if cnt > K:
    print(1)
else:
    print(int(s))

### FIXED CODE ###

import numpy as np
S = np.array(list(map(str, input().rstrip())))
K = int(input())

cnt = 0
ans = 1

for i, s in enumerate(S):
    if s != "1":
        cnt = i+1
        ans = s
        break

if cnt > K:
    print(1)
else:
    print(int(ans))
N = int(input())
a = list(map(int, input().split()))

for i in a:
    if i % 2 == 0:
        if (i % 3 == 0) or (i % 5 == 0):
            continue
        else:
            print('DENIED')
            sys.exit()

print('APPROVED')


### FIXED CODE ###


import sys


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

for i in a:
    if i % 2 == 0:
        if (i % 3 == 0) or (i % 5 == 0):
            continue
        else:
            print('DENIED')
            sys.exit()

print('APPROVED')