peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
MOD = 10**9 + 7

import sys
input = sys.stdin.readline

n, m = map(int, input().split())
a = [0] * (n + 1)
for _ in range(m):
    a[int(input())] = 1

# i段目にたどり着く方法
dp = [0] * (n + 1)
dp[0] = 1
dp[1] = 1 if a[1] == 0 else 0

for i in range(2, n+1):
    dp[i] = (dp[i-1] + dp[i-2]) % MOD if a[i] == 0 else 0

print(dp[-1])
# Judge status: Wrong Answer
n = int(input())
s = set()

ok = True
t = input()
p = t[-1]
for i in range(n-1):
  t = input()
  if t in s:
    ok = False
  s.add(t)
  if t[0] != p:
    ok = False
  p = t[-1]
  
print('Yes' if ok else 'No')
# Judge status: Accepted
a, b = map(int, input().split())
if a * b <= 0:
    print("Zero")
elif a > 0:
    print("Positive")
else:
    if (b - a) % 2 == 0:
        print("Negative")
    else:
        print("Positive")
# Judge status: Accepted
x = int(input())
if x < 30:
    print("No")
else:
    print("Yes")
# Judge status: Wrong Answer
from collections import Counter
n = int(input())
s = []
for _ in range(n):
    s.append(str(input()))

s_c = Counter(s).most_common()
m = s_c[0][1]

print(s_c)
print(m)
ans = []

for j in range(len(s_c)):
    if s_c[j][1] != m:
        break
    else:
        ans.append(s_c[j][0])
        
ans.sort()

for k in ans:
    print(k)
# Judge status: Accepted
n = int(input())
ans = 0

def solve(x):
    df = str(x)[0]
    dl = str(x)[-1]
    return df, dl

numMap = {}

for i in range(1, n+1):
    # print(i)
    # print(solve(i))
    pair = solve(i)
    if pair in numMap:
        numMap[pair] += 1
    else:
        numMap[pair] = 1

for i in range(1, n+1):
    key = solve(i)
    rev = key[::-1]
    # print('key:', key)
    # print('rev:', rev)
    if rev in numMap:
        ans += numMap[rev]

# print(numMap)
print(ans)
# Judge status: Wrong Answer
N = int(input())
B = list(map(int,input().split()))
A = []
A.append(B[0])
A.append(B[0])
for i in range(1, N - 2):
  if B[i] < A[i]:
    A[i] = B[i]
  
  if N != 2:
    A.append(B[i])

print(sum(A))
# Judge status: Accepted
S,T=input().split()
print(T,S,sep='')
# Judge status: Accepted
n = int(input())
p = list(map(int,input().split()))
ans = 0
tmp = 2*10**5+1
for i in range(n):
    if tmp > p[i]:
        ans+=1
        tmp = p[i]
        if p[i]==1:
            break
print(ans)
# Judge status: Accepted
n = int(input())
b = ''
while n:
  b = str(n%2)+b
  n = -(n//2)
print(b if b else 0)
# Judge status: Accepted
N, M, X, Y = map(int, input().split())
XL = list(map(int, input().split())) + [X]
YL = list(map(int, input().split())) + [Y]
XL.sort()
YL.sort(reverse=True)
xt = XL.pop()
yt = YL.pop()
if xt < yt:
    print('No War')
else:
    print('War')
# Judge status: Wrong Answer
"""Boot-camp-for-Beginners_Easy011_B_Collatz-Problem_29-August-2020.py"""
import numpy as np

N = 100
# N=int(input())
Division_2 = []
number=[]
for i in range(1, N+1):
    j = i
    count = 0
    while True:
        count += 1
        j = j/2
        if j/2 != int(j/2):
            break
    Division_2.append(count)
    number.append(i)
Division_2=np.array(Division_2)
print(number[np.argmax(Division_2)])
# Judge status: Accepted
a1, a2, a3 = map(int, input().split())
if a1 + a2 + a3 >= 22:
  print('bust')
else:
  print('win')
# Judge status: Accepted
# sumitb2019_b_bacha.py
N = int(input())
for i in range(50000):
    if int(i*1.08) == N:
        print(i)
        exit()
print(":(")
# Judge status: Wrong Answer
n,l = map(int,input().split())
for i in range(n):
  s = sorted([input()])
  print(*s,sep="")
# Judge status: Accepted
s=list(input())
if 'L' in s[::2] or 'R' in s[1::2]:
    print('No')
else:
    print('Yes')
# Judge status: Accepted
import collections
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
	a.append(a[i]+1)
	a.append(a[i]-1)
c = collections.Counter(a)
print(c.most_common()[0][1])
# Judge status: Accepted
s=input()
ans=999
for i in range(len(s)-2):
  t=int(s[i:i+3])
  ans=min(ans,abs(753-t))
print(ans)
# Judge status: Accepted
A,B,N = map(int,input().split())
m = 0
if B-1 >=N:
    print(int(A*N/B)-A*int(N/B))
else:
    print(int(A*(B-1)/B)-A*int((B-1)/B))
# Judge status: Accepted
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

As = [0] * (n + 1)
Bs = [0] * (m + 1)
for i in range(n):
  As[i + 1] = A[i] + As[i]
for i in range(m):
  Bs[i + 1] = B[i] + Bs[i]

l = 0
r = n + m + 1
while r - l > 1:
  p = (l + r) // 2
  best = k + 1
  for i in range(p + 1):
    if min(i, n) + min(p - i, m) < p:
      continue
    best = min(best, As[i] + Bs[p - i])
  if best <= k:
    l = p
  else:
    r = p
print(l)
# Judge status: Accepted
# B
n, m = map(int, input().split())
count = [0]*m
for i in range(n):
    a = list(map(int, input().split()))
    for j in range(1, a[0]+1):
        count[a[j]-1] += 1
        
print(count.count(n))
# Judge status: Accepted
x, a, b = (int(i) for i in input().split())

n = b - a
if n <= 0:
  print('delicious')
elif n <= x:
  print('safe')
else:
  print('dangerous')
# Judge status: Accepted
s = list(map(int,input().split()))

h = 60 * (s[2]-s[0])
m = s[3] - s[1]
k = s[4]
print(h+m-k)
# Judge status: Accepted
a,b=map(int,input().split())
print("Possible" if ((a+b)%3==0 or a%3==0 or b%3==0) else "Impossible")
# Judge status: Accepted
import sys
input = sys.stdin.readline
A, B = [int(x) for x in input().split()]
if A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0:
    print("Possible")
else:
    print("Impossible")
# Judge status: Accepted
def is_prime(n):
    if n==1:
        return False
    else:
        for i in range(2, int(n**0.5)+1):
            if n % i == 0:
                return False
    return True

x = int(input())

while not is_prime(x):
    x += 1

print(x)
# Judge status: Accepted
N = int(input())
list_A = list(map(int,input().split()))
B = [0]*N

for a in list_A:
    B[a-1] += 1

for i in range(N):
    print(B[i])
# Judge status: Accepted
from collections import Counter

lst = list(input())

c = Counter(lst)

A = c['a']
B = c['b']
C = c['c']

if max(max(A, B), C) - min(min(A, B), C) <= 1:
    print ('YES')
else:
    print ('NO')
# Judge status: Wrong Answer
N=int(input())
A=list(map(int,input().split()))
import fractions
ans=A[0]
for i in range(1,N):
  ans=ans*A[i]//fractions.gcd(ans,A[i])
ans%=(10**9+7)
w=0
for i in A:
  w+=(ans//i)%(10**9+7)
  
print(w)
# Judge status: Accepted
s = input()
i = len(s)
while i > 0:
    if s[i-5:i] == 'dream' or s[i-5:i] == 'erase':
        i -= 5
    elif s[i-6:i] == 'eraser':
        i -= 6
    elif s[i-7:i] == 'dreamer':
        i -= 7
    else:
        print('NO')
        exit()
print('YES')
# Judge status: Accepted
import sys
import math

A,B,C,D = map(int, input().split())
def lcm(x, y):
    return (x * y) // math.gcd(x, y)


maru1 = B // C
maru2 = (A-1) // C

maru3 = B // D
maru4 = (A-1) // D

maru5 = B // lcm(C,D)
maru6 = (A-1) // lcm(C,D)

ans_tmp = ((maru1-maru2)+(maru3-maru4)) - (maru5-maru6)
ans = (B-A+1) - ans_tmp

print(ans)
# Judge status: Wrong Answer
n,*a=map(int,open(0).read().split())
print("Yes" if sum(j-i if j-i>0 else 2*(j-i)for i,j in zip(a[:n],a[n:]))>=0 else "No")
# Judge status: Accepted
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]

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

if (a%3==0 or b%3==0 or (a+b)%3==0):
    print("Possible")
else:
    print("Impossible")
# Judge status: Accepted
input()
A = list(map(int, input().split()))
count = 0
while all(a % 2 == 0 for a in A):
    A = [a/2 for a in A]
    count += 1
print(count)
# Judge status: Wrong Answer
N, M = map(int, input().split())
if N % 2 == 0:
    print(1, 1 + N // 2)
    for m in range(M):
        if m % 2 == 0:
            print(m + 2, N // 2 - m)
        else:
            print(N // 2 + m, N - m)
else: 
    for m in range(M):
        print(m + 1, N - m)
# Judge status: Wrong Answer
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
res = 0
for i in range(n):
  c = 0
  for j in range(n):
    if j <= i:
      c += a[j]
    else:
      c += b[j]
  res = max(res,c)
print(res)
# Judge status: Accepted
import math
H = int(input())
count = 0
attack = 0

while H >= 1:
  H = H/2
  count += 1

for num in range(count):
  attack = attack + 2**num

print(attack)
# Judge status: Accepted
import fractions
import sys
input = sys.stdin.readline

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

n,m = map(int,input().split())
a = list(map(int,input().split()))
g = a[0]

for i in range(1, n):
    g = g * a[i] // gcd(g, a[i])

for i in a:
    if g // 2 % i == 0:
        print(0)
        exit()

print(-(-(m * 2 // g)//2))
# Judge status: Accepted
n, a, b = map(int, input().split())
mod =  10**9 + 7

def calculate_combination(n, k):
    x, y = 1, 1
    for i in range(k):
        x = x * (n-i) % mod
        y = y * (k-i) %mod
    return x * pow(y, mod-2, mod) % mod

ans = pow(2, n, mod)-1 - calculate_combination(n, a) - calculate_combination(n, b)
while ans < 0:
    ans += mod
print(ans)
# Judge status: Wrong Answer
# input
N, M = map(int, input().split())

# check
if 2 in [M, N] or N == M == 1:
    print(0)
elif 1 in [M, N]:
    print(N * M - 2)
else:
    print(N * M - (2 * (N + M) - 4))
# Judge status: Accepted
n = int(input())
x_1 = list(map(int, input().split()))
x_2 = sorted(x_1)
median_1 = x_2[n//2-1]
median_2 = x_2[n//2]
for v in x_1:
    if v <= median_1:
        print(median_2)
    else:
        print(median_1)
# Judge status: Accepted
s = input()

count=0
for i in range(len(s)//2):
    if s[i] != s[-1-i]:
        count+=1
print(count)
# Judge status: Wrong Answer
s=input()
t=input()
for i in range(len(t),0,-1):
    for j in range(0,len(t)-i+1):
        sum=t[j:j+i]
        if sum in s[j:]:
            k=s[j:].find(sum)
            if len(s)-(k+j)>=len(t):
                print(sum,j,k)
                print(len(t)-len(sum))
                exit()
print(len(t))
# Judge status: Wrong Answer
n=int(input())
k=int(input())
x=int(input())
y=int(input())
if n <= k:
    print(n*y)
else:
    print(k*x+ (n-k)*y)
# Judge status: Accepted
x = int(input())
money = 100
i=0
while(money<x):
	money = int(money*1.01)
	i+=1
print(i)
# Judge status: Accepted
from string import ascii_lowercase
alpha = {i for i in ascii_lowercase}
s = set([i for i in input()])
ans = sorted(alpha - s)
if ans==[]:
    print('None')
else:
    print(ans[0])
# Judge status: Accepted
n=int(input())
mas=list(map(int,input().split()))
out=[]
mx=0
i=0
while i<n:
  if mx>n-i:
    break
  j=i
  ans=0
  while j<n-1:
    if mas[j]>=mas[j+1]:
      ans+=1
    else:
      break
    j+=1
  
  if ans>mx:
    mx=ans
  i+=ans+1
  
print(mx)
# Judge status: Wrong Answer
A,B,C,K = map(int, input().split())
MAX = 10**18
for i in range(K):
    temp_a = A
    temp_b = B
    temp_c = C
    A = temp_b + temp_c
    B = temp_a + temp_c
    C = temp_a + temp_b
    if A > MAX or B > MAX or C > MAX:
        print("Unfair")
        exit()
if abs(A-B) > MAX:
    print("Unfair")
else:
    print(A-B)
# Judge status: Accepted
k = int(input())
ans = []


def dfs(x):
    if x > 10**10:
        return 0
    else:
        ans.append(x)
        y = x % 10
        for i in range(10):
            if abs(y-i) <= 1:
                dfs(10*x+i)
                
for i in range(1, 10):
    dfs(i)
ans.sort()
print(ans[k-1])
# Judge status: Wrong Answer
from itertools import permutations
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
pi = 0
qi = 0
cnt = 0
for p in permutations(range(1,1+N)):
    cnt += 1
    #print(p)
    if p == P:
        pi = cnt
    elif p == Q:
        qi = cnt
        
print(abs(qi-pi))
# Judge status: Accepted

x = int(input())
i = 1
while x*i%360 != 0:
    i+= 1

print(i)
# Judge status: Accepted
N,C,K=list(map(int,input().split()))
import sys
l=[r.rstrip() for r in sys.stdin.readlines()]
l=list(map(int,l))
l.sort()
ans=0
now=0
for i in range(N):
   X=l[now]
   for j in range(C):
      if X <= l[now] <= X+K:
         now+=1
         if now==N:
            break
      else:
         break
   ans+=1
   if now==N:
      break
print(ans)
# Judge status: Accepted
R = int(input())

print(2*3.14159*R)
# Judge status: Accepted
S = input()

cnt = 0
ans = 0
for s in S:
    if s not in ("A", "C", "G", "T"):
        cnt = 0
    else:
        cnt += 1
    ans = max(ans, cnt)
print(ans)
# Judge status: Accepted
from fractions import gcd

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

print('YES' if C % gcd(A, B) == 0 else 'NO')
# Judge status: Accepted
d=int(input())
print("Christmas" + " Eve"*(25-d))
# Judge status: Accepted
n = int(input())
l = list(map(int,input().split()))

s = sum(l)
m = max(l)

if m<s-m:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
N = input()
print('ABC' if N == 'ARC' else 'ABC')
# Judge status: Accepted
S = input()
T = input()

a = T.find(S)
if a == 0:
    T = T[len(S):]
    if len(T) == 1:
        print("Yes")
    else:
        print("No")
else:
        print("No")
# Judge status: Wrong Answer
x, a, b = map(int, input().split())

if abs(a - x) > abs(b - x):
    print("A")
else:
    print("B")
# Judge status: Accepted
# solution
import io
import math
import heapq
import bisect

MOD = 10**9+7

N = int(input())
array = list(map(int, input().split()))
array.sort()

result = 0
for a in range(N-2):
    for b in range(a+1,N-1):
        c = bisect.bisect_left(array,array[a]+array[b])
        result += c-b-1
            
print(result)
# Judge status: Accepted
n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
ans=0
for i in range(n):
    if x>=a[i]:
        x-=a[i]
        ans+=1
    else:
        break
else:
    if x>0:
        ans-=1
print(ans)
# Judge status: Accepted
x = int(input())
ans = 0
ans += x//500*1000
x = x%500
ans += x//5*5
print(ans)
# Judge status: Accepted
import math

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

mod = 10**9 +7

sn = (n*(n+1)*(n+2)/6 +n+1)% mod
sk = ((k-1)*k*(3*n-2*k+4)/6 +k-1)% mod

snk = math.floor((sn - sk)% mod)

print(snk)
# Judge status: Accepted
n, m = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(n)]
cd = [tuple(map(int, input().split())) for _ in range(m)]

dist = [0] * m

for a, b in ab:
    dist = [0] * m
    for j in range(m):
        dist[j] = abs(a-cd[j][0]) + abs(b-cd[j][1])
    ans = dist.index(min(dist)) + 1
    print(ans)
# Judge status: Accepted
from operator import mul
from functools import reduce

def combinations_count(n, r):
    if n<r: return 0
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

def main():
    N,M = map(int, input().split())
    ans = combinations_count(M,2) + combinations_count(N,2)
    print(ans)

main()
# Judge status: Wrong Answer
from collections import deque as dq

n = int(input())
a = dq(int(i) for i in input().split())
l = [0] * (n - 1)

for i in a:
    l[i - 1] += 1

for i in l:
    print(i)
# Judge status: Wrong Answer
n = int(input())
aa = list(map(int, input().split()))
c2 = 0
c4 = 0

for a in aa:
  if a % 4 == 0:
    c4 += 1
  elif a % 2 == 0:
    c2 += 1
if c2 == 0 and c4 == 0:
    print('No')
    exit()

if c4 + c2 == n:
  print('Yes')

elif n/2 -1 < c4 < n/2 + 1:
  print('Yes')
  
elif n % 4 == 2:
  if c4 == n / 2 - 1 and c2 == 2:
    print('Yes')
else:
  print('No')
# Judge status: Accepted
S = str(input())
K = int(input())
s = list(S)

i = 0
p = 0
for i in range(len(s)):
    s[i] = int(s[i])
i = 0
while  i < len(s):
    if s[i] == 1:
        p = i + 1
    else:
        q = s[i]
        break
    i = i+1
if K < p + 1:
    print(1)
else:
    print(q)
# Judge status: Wrong Answer
n=int(input())
h =list(map(int,input().split()))
if n ==1:
        print('Yes')
        exit()
for i in range(n-1):
        if h[i] >= h[i+1]:
                h[i] -=1
if h == sorted(h):
        print('Yes')

else:
        print('No')
# Judge status: Accepted
from sys import stdin,stdout
for _ in range(1):#int(stdin.readline())):
    # n=int(stdin.readline())
    x,k,d=list(map(int,stdin.readline().split()))
    '''if x==k==d:
        print(0 if k&1 else x)
        continue'''
    x=abs(x)
    des=x%d
    op=x//d
    # print(des,op)
    a=[des,des-d]
    if k<op:#check for eq
        print(x-k*d)
    else:
        print(abs(a[(k-op)%2]))
# Judge status: Accepted
n, k = [int(w) for w in input().split()]

d = 0
while n != 0:
    n //= k
    d += 1

print(d)
# Judge status: Wrong Answer
n,m = map(int,input().split())
lists = list(map(int, input().split()))
lists.sort()

sums = sum(lists)/4/m
lens = len(lists)
for i in range(m):
    if lists[lens-1-i] < sums:
        print("No")
        break

print("Yes")
# Judge status: Accepted
N, K = map(int, input().split())
p = list(map(int, input().split()))

p.sort()
print(sum(p[:K]))
# Judge status: Wrong Answer
import math

N = int(input())

a = math.floor(math.sqrt(N))

while N % a != 0:
    a -= 1

b =N/a
print(a + b -2)
# Judge status: Accepted
d,n = map(int, input().split())
print((100**d)*n if n <= 99 else (100**d)*101)
# Judge status: Accepted
n, m = map(int, input().split())
s = [1] * (n + 1)
for i in range(m):
    a = int(input())
    s[a] = 0
for i in range(2, n + 1):
    if s[i] == 0:
        continue
    else:
        if s[i - 2] == 0 and s[i - 1] == 0:
            print(0)
            exit()
        else:
            s[i] = s[i - 1] + s[i - 2]   
print(s[n] % 1000000007)
# Judge status: Accepted
N, M = map(int, input().split())

res = [0] * (M + 1)

for _ in range(N):
    A = list(map(int, input().split()))
    K = A.pop(0)
    for a in A:
        res[a] += 1

ans = 0

for r in res:
    if r == N:
        ans += 1

print(ans)
# Judge status: Wrong Answer
X, Y = map(int, input().split())
res = 0
while X < Y:
    res += 1
    X *= 2
print(res)
# Judge status: Wrong Answer
import sys
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

if a>b or w>v:
    print('NO')
    sys.exit()
for tt in range(1,t):
    res = (w - v) * tt + (b - a)
    if res == 0:
        print('YES')
        sys.exit()

print('NO')
# Judge status: Accepted
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

a = inpl()
print(a[2],a[0],a[1])
# Judge status: Accepted
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    x, y = map(int, readline().split())

    if x % y == 0:
        print(-1)
    else:
        print(x * (y - 1))


if __name__ == '__main__':
    main()
# Judge status: Accepted
H = int(input())
W = int(input())
N = int(input())

print((N + max(H, W) - 1) // max(H, W))
# Judge status: Accepted
n = int(input())
pl = list(map(int, input().split()))

count = 1
min_e = pl[0]
for e in pl[1:]:
    if (e < min_e):
        count += 1
        min_e = e
print(count)
# Judge status: Accepted
import itertools
N,M = map(int,input().split())
ary1 = map(int,input().split())
if N>=M:
  print(0)
else:
  ary2 = sorted(list(ary1))
  ary3 = ary2[1:]
  ary4 = ary2[:-1]
  d1  = ary2[M-1]-ary2[0]
  dist1 = sorted([i-j for i,j in zip(ary3,ary4)])[M-N:M]
  d2 =  sum(dist1)
  print(d1-d2)
# Judge status: Accepted
import sys

input = sys.stdin.readline

def main():
    N = int(input())
    Z = []; W = []
    for i in range(N):
        x, y = map(int, input().split())
        z = x + y
        w = x - y
        Z.append(z)
        W.append(w)
    ans = max(max(Z) - min(Z), max(W) - min(W))
    print(ans)

if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
max = int(input()) - 1

cnt = 0
for A in range(max):
    for B in range(max):
        if A*B > max:
            break
        cnt += 1
# Judge status: Wrong Answer
N = int(input())

dp = [[0] * 10 for _ in range(10)]
for x in range(1, N + 1):
    j = x % 10
    while x > 10:
        x //= 10
    i = x % 10
    dp[i][j] += 1
    
ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += dp[i][j] * dp[j][i]
        
print(ans)
# Judge status: Wrong Answer
a, b, c = list(map(int, input().split()))
if b-a == c-b:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
import math
n,x,t = map(int, input().split())
print(math.ceil(n/x)*t)
# Judge status: Accepted
N,M=list(map(int,input().split()))
 
g=[[] for i in range(N+1)]
 
for i in range(M):
	a,b=list(map(int,input().split()))
	g[a].append(b)
	g[b].append(a)
 
from collections import deque
 
queue = deque([1])
d = [None] * (N+1)
while queue:
	v = queue.popleft()
	for i in g[v]:
		if d[i] is None:
			d[i] = v
			queue.append(i)
 
print("Yes")
print(*d[2:],sep='\n')
# Judge status: Accepted
#!/usr/bin/env python3

A = int(input())
B = int(input())

for i in [1, 2, 3]:
    if i != A and i != B:
        print(i)
# Judge status: Accepted
l=list(map(int,input().split()))
print(max(0,min(l[1],l[3])-max(l[0],l[2])))
# Judge status: Accepted
a, b = map(int, input().split())
s = str(input())
lst = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0']
for i in range(len(s)):
    if(i != a):
        if(s[i] not in lst):
            print("No");
            exit(0)
    else:
        if(s[i] != '-'):
            print("No");
            exit(0)
print("Yes")
# Judge status: Wrong Answer
a,b,c=(int(x) for x in input().split())
if a < b < c:
    print( 'A' )
elif a < c < b:
    print( 'A' )
elif b < a < c:
    print( 'B' )
elif b < c < a:
    print( 'B' )
else:
    print( 'C' )
# Judge status: Wrong Answer
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


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

LCM = A[0]

for i in range(1, N):
    LCM = lcm(LCM, A[i])

ans = 0
for i in range(N):
    ans += (LCM // A[i]) % MOD

# print(LCM)
print(ans)
# Judge status: Accepted
import bisect
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort(),c.sort()
x=len(c)
ans=0
for bi in b:
  xa=bisect.bisect_right(c,bi)
  xb=bisect.bisect_left(a,bi)
  ans+=xb*(x-xa)
print(ans)
# Judge status: Wrong Answer
h,a = map(int,input().split())
b = h/a
if b%1 == int(0):
    print(b)
elif b%1 < 0:
    print(1)
else:
    print(b//1)
# Judge status: Accepted
n = int(input())
s = input()
t = input()

for zurasu in range(0, n+1):
    if s[zurasu:] == t[:n-zurasu]:
        print(n+zurasu)
        exit(0)
# Judge status: Wrong Answer
from collections import Counter
N = int(input())
D = list(map(int, input().split()))
D = Counter(D)

ans = 0
cnt = 0
if D[0] == 1:
  cnt = 1
  ans = 1
  for i in range(1, max(D)+1):
    if D[i] == 0:
      ans = 0
      break
    else:
      ans *= cnt ** D[i]
      cnt = D[i]
ans = ans % 998244353
print(ans)
# Judge status: Wrong Answer
n=int(input())

l=[]
for i in range(n):
  a,b=map(str, input().split())
  b=100-int(b)
  if b<10:
    b=str('0')+str(b)
  else:
    b=str(b)
  a=a+b
  l.append(a)

l2=sorted(l)

for i in range(n):
  print(l.index(l2[i])+1)
# Judge status: Wrong Answer
x,y = map(int,input().split())
if x == y:
    print(0)
elif x < y:
    print(y-x)
else:
    if x > 0 and y >= 0:
        print(1+abs(x-y))
    elif x > 0 and y < 0:
        if x+y >= 0:
            print(1+x+y)
        else:
            print(1+abs(x+y))
    else:
        print(2+x-y)
# Judge status: Accepted
n = int(input())
a = [int(k) for k in input().split()]
cnt = 0
for i in range(n):
  if a[i] != i+1:cnt += 1
print("YES" if cnt <= 2 else "NO")
# Judge status: Accepted
a, b, c = map(int, input().split())
cnt = 0

while cnt <= 10**6:
    if (a%2 != 0 or b%2 != 0 or c%2 != 0):
        print(cnt)
        exit()
    
    if a==b==c:
        print(-1)
        exit()
    
    a_ = b//2 + c//2
    b_ = a//2 + c//2
    c_ = a//2 + b//2

    a = a_
    b = b_
    c = c_

    cnt += 1
# Judge status: Accepted
import math
import sys

input = sys.stdin.readline
a, b, c = map(int, input().split())
x = (a//2)*b*c
x = abs(abs(x-a*b*c)-x)
y = (b//2)*a*c
y = abs(abs(y-a*b*c)-y)
z = (c//2)*a*b
z = abs(abs(z-a*b*c)-z)

print(min(x, y, z))