Harryxun/stf_run huggingface dataset:
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

import math 

a,b,c,d = mi()

g = c*d//math.gcd(c,d)

# cの倍数の個数
ac = (a-1)//c
bc = b//c
nc = bc-ac

# dの倍数の個数
ad = (a-1)//d
bd = b//d 
nd = bd-ad

# cdのgcdの倍数の個数
ag = (a-1)//g
bg = b//g
ng = bg-ag

ans = b-(a-1)-nc - nd + ng

# print(g,nc,nd,ng)
print(int(ans))

### FIXED CODE ###

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

import fractions

a,b,c,d = mi()

g = c*d // fractions.gcd(c,d)

# cの倍数の個数
ac = (a-1)//c
bc = b//c
nc = bc-ac

# dの倍数の個数
ad = (a-1)//d
bd = b//d
nd = bd-ad

# cdのgcdの倍数の個数
ag = (a-1)//g
bg = b//g
ng = bg-ag

ans = b-(a-1)-nc - nd + ng

# print(g,nc,nd,ng)
print(ans)
t = list(input())

if t[0] == "?":
    if t[1] == "P":
        t[0] = "D"
    else:
        t[0] = "P"
for i in range(1, len(t)-1):
    if t[i-1] == "P":
        t[i] = "D"
    elif t[i+1] == "D":
        t[i] = "P"
    elif t[i+1] == "?":
        t[i] = "P"
        t[i+1] = "D"
    else:
        t[i] = "D"
if t[-1] == "?":
    t[-1] = "D"

print("".join(t))

### FIXED CODE ###

t = list(input())

if len(t) == 1 and t[0] == "?":
    t[0] = "D"
    print(t[0])
    exit()

if t[0] == "?":
    if t[1] == "P":
        t[0] = "D"
    else:
        t[0] = "P"
for i in range(1, len(t)-1):
    if t[i] == "?" and t[i-1] == "P":
        t[i] = "D"
    elif t[i] == "?" and t[i+1] == "D":
        t[i] = "P"
    elif t[i] == "?" and t[i+1] == "?":
        t[i] = "P"
        t[i+1] = "D"
    elif t[i] == "?":
        t[i] = "D"
if len(t) > 1:
    if t[-1] == "?":
        t[-1] = "D"

print("".join(t))
class Node:
    def __init__(self, num, parent, children):
        self.id = num
        self.parent = -1
        self.depth = 0
        self.type = None
        self.children = children

    def show_info(self):
        print('node {0}: parent = {1}, depth = {2}, {3}, {4}'.format(self.id, self.parent, self.depth,self.type, self.children))


def set_node(i_s):
    num, children = i_s[0], i_s[2:]
    node = Node(num, -1, children)
    T[num] = node
    for n in children:
        T[-1] -= n


def set_pdt(n_i, parent, depth):
    node = T[n_i]
    node.parent = parent
    node.depth = depth
    if node.children:
        node.type = 'internal node'
        for n in node.children:
            set_pdt(n, n_i, depth + 1)
    else:
        node.type = 'leaf'



n = int(input())
tree = [list(map(int, input().split())) for i in range(n)]
T = [None] * n

T += [int(n * (n - 1) / 2)]

for i in range(n):
    set_node(tree[i])
set_pdt(1, -1, 0)

T[0].type ='root'

for n in T[:-1]:
    n.show_info()

### FIXED CODE ###



class Node:
    def __init__(self, num, children):
        self.num = num
        self.children = children
        self.parents = -1
        self.type = None
        self.depth = 0

    def output(self):
        print('node {0}: parent = {1}, depth = {2}, {3}, {4}'.format(self.num,
                                                                      self.parents,
                                                                      self.depth,
                                                                      self.type,
                                                                      self.children))


def set_node(num, children):
    node = Node(num, children)
    T[num] = node
    for n in children:
        T[-1] -= n  # ?????£???T[-1]???root???????????????????????????


def set_pdt(n_i, parent, depth):
    node = T[n_i]
    node.parents = parent
    node.depth = depth
    if node.children:
        node.type = 'internal node'
        for n in node.children:
            set_pdt(n, n_i, depth + 1)
    else:
        node.type = 'leaf'


n = int(input())
tree = [list(map(int, input().split())) for i in range(n)]
T = [None] * n
T += [n * (n - 1) // 2]
for j in tree:
    set_node(j[0], j[2:])

set_pdt(T[-1], -1, 0)

T[T[-1]].type = 'root'

for n in T[:-1]:
    n.output()
n=int(input())
a=[]
for i in range(n):
  a.append(int(input()))
keep=1
count=0
ababa=0
for i in range(n):
  count+=1
  keep=a[keep-1]
  if keep==2:
    ababa=1
    print(count)
    break
if ababa=0:
  print(-1)

### FIXED CODE ###

n=int(input())
a=[]
for i in range(n):
  a.append(int(input()))
keep=1
count=0
ababa=0
for i in range(n):
  count+=1
  keep=a[keep-1]
  if keep==2:
    ababa=1
    print(count)
    break
if ababa==0:
  print(-1)
k,x =list(map(int,input().split()))

start = x - k+1
end = x + k-1

ans = ''
for i in range(start,end+1):
    ans += f'{i} '
ans = ans[:-1]

print(ans)


### FIXED CODE ###

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

start = x - k+1
end = x + k-1

ans = ''
for i in range(start,end+1):
    ans += '{} '.format(i)
ans = ans[:-1]

print(ans)
n,m,k=map(int,input().split())
n,m=min(n,m),max(n,m)
for i in range(n//2+n%2):
  num,dem=k-i*m,n-2*i
  if num%dem or not(0<=num///dem<=m):continue
  print("Yes");exit()
print("No")

### FIXED CODE ###

n,m,k=map(int,input().split())
n,m=min(n,m),max(n,m)
for i in range(n//2+n%2):
  num,dem=k-i*m,n-2*i
  if num%dem or not(0<=num//dem<=m):continue
  print("Yes");exit()
print("No")
from functools import reduce
from operator import xor
from itertools import chain

def main():
    M,K = map(int,input().split())

    if K == 0:
        def it():
            for i in range(2**M):
                yield i
                yield i
        print(*it())
        return

    # check
    r = reduce(xor, chain(range(2**M),(K,)))

    if r == K:
        print(*reversed(range(2**M)),K,*range(2**M),K)
    else:
        print(-1)

if __name__ == '__main__':
    main()

### FIXED CODE ###

from functools import reduce
from operator import xor
from itertools import chain

def main():
    M,K = map(int,input().split())

    if K >= 2**M:
        print(-1)
        return

    if M >= 2:
        def it():
            for i in reversed(range(2**M)):
                if i != K:
                    yield i
            yield K
            for i in range(2**M):
                if i != K:
                    yield i
            yield K
        print(*it())
    elif M == 1:
        if K == 0:
            print(0,0,1,1)
        else:
            print(-1)
    else:
        print(0, 0)

if __name__ == '__main__':
    main()
# k=(int)(input())
import math
a,b,n=map(int,input().split())
if(n<=b):
    print(math.floor((a*n)/b))
else:
    print(math.floor((a*b-1)/b))


### FIXED CODE ###

k = int(input())
a,b = map(int,input().split())
ans = 'NG'
for i in range(a,b+1):
    if i%k == 0:
        ans = 'OK'
        break
print(ans)
x=input()
print(x**3)

### FIXED CODE ###

print(int(input())**3)
import random
k = int(input())
a, b = map(int, input().split())
c = random.randrange(a, b)
if c % k == 0:
  print('OK')
else:
  print('NG')

### FIXED CODE ###

k = int(input())
a,b = map(int, input().split())
 
if (b // k) * k >= a:
  print('OK')
else:
  print('NG')
n = int(input())
A = map(int,input().split())

cnt = 0

for a in A:
    while (a % 2 == 0):
        cnt = cnt + 1
        a = a / 2

print(cnt)

### FIXED CODE ###

a,b = map(int,input().split())
if (a <= 8 and b <= 8):
    print("Yay!")
else:
    print(":(")
s = input()
n = len(s)
if n%2 == 1
	print("No")
else
	if s[:n/2] == s[n/2:]
		print("Yes")
	else
		print("No")

### FIXED CODE ###

m = input()
s = input()
n = len(s)
f = int(n/2)
if n%2 == 1:
	print("No")
else:
	if s[:f] == s[f:]:
		print("Yes")
	else:
		print("No")
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd
# fractions.gcd() を用いること
# math.log2()はatcoderでは対応していない．留意せよ．

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    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 find_gcd(list_l):
    x = reduce(gcd, list_l)
    return x


def main():
    S = input().strip()
    n = int(input().strip())
    for i in range(len(S)):
        if S[i]!='1':
            m=i
            s=S[i]
            break
    if n<m:
        print("1")
        return
    else:
        print(s)
        return


    


if __name__ == '__main__':
    main()

### FIXED CODE ###

from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd
# fractions.gcd() を用いること
# math.log2()はatcoderでは対応していない．留意せよ．

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    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 find_gcd(list_l):
    x = reduce(gcd, list_l)
    return x


def main():
    S = input().strip()
    n = int(input().strip()) - 1
    m=0
    for i in range(len(S)):
        if S[i] != '1':
            m = i
            break
    if n < m:
        print("1")
        return
    else:
        print(S[m])
        return


if __name__ == '__main__':
    main()
a=list(int(input()) for i in range(5))

b=[-(-a[i]//10)*10 for i in range(5)]
c=[a[i]%10 for i in range(5) if a[i]%10 != 0]
print(b)

print(sum(b) + min(c) -10)


### FIXED CODE ###

a=list(int(input()) for i in range(5))

b=[-(-a[i]//10)*10 for i in range(5)]
c=[a[i]%10 for i in range(5) if a[i]%10 != 0]

if c != []:
    print(sum(b) + min(c) -10)
else:
    print(sum(b))
target_list = []
for a, b, c in zip(A, B, C):
    if a==b and b==c:
        target_list.append(3)
    elif a==b or a==c:
        target_list.append(2)
    else:
        target_list.append(1)
print(N*3 - sum(target_list))

### FIXED CODE ###

N = int(input())
A = input()
B = input()
C = input()
target_list = []
for a, b, c in zip(A, B, C):
    if a==b and b==c and c==a:
        target_list.append(3)
    elif a==b or b==c or c==a: 
        target_list.append(2)
    else:
        target_list.append(1)
print(N*3 - sum(target_list))
import collections

n = int(input())
List = [input() for i in range(n)]
res = []

c = collections.Counter(List)

for v in c.values():
  m = max(m, v)
  
for k, v in c.items():
  if v == m:
    res.append(k)
    
res.sort()
for i in range(les(res)):
  print(res[i])

### FIXED CODE ###

import collections

n = int(input())
List = [input() for i in range(n)]
res = []

c = collections.Counter(List)
m = 0
for v in c.values():
  m = max(m, v)
  
for k, v in c.items():
  if v == m:
    res.append(k)
    
res.sort()
for i in range(len(res)):
  print(res[i])
from sys import stdin

N=int(input())
xlist=[]
ylist=[]
dict = {}
for i in range(N):
  x, y = map(int, stdin.readline().rstrip().split())
  xlist.append(x)
  ylist.append(y)

tupleList=[]
for i in range(N):
  for j in range(N):
    if i != j:
      tuple = (xlist[i] - xlist[j], ylist[i] - ylist[j])
      if tuple in dict:
        dict[tuple]+=1
      else:
        dict[tuple]=1

print(N-max(dict.values()))


### FIXED CODE ###

from sys import stdin

N=int(input())
xlist=[]
ylist=[]
dict = {}
for i in range(N):
  x, y = map(int, stdin.readline().rstrip().split())
  xlist.append(x)
  ylist.append(y)

for i in range(N):
  for j in range(N):
    if i != j:
      tupleStr=str(xlist[i] - xlist[j])+","+str(ylist[i] - ylist[j])
      if tupleStr in dict:
        dict[tupleStr]+=1
      else:
        dict[tupleStr]=1

maxNum=0
for val in dict.values():
  maxNum = max(maxNum, val)

print(N-maxNum)
N = int(input())

x_list=[]
y_list=[]
h_list=[]

def all_same(items):
	return all(map(lambda x: x == items[0], items))

for i in range(N):
	x,y,h=map(int, input().split())
	x_list.append(x)
	y_list.append(y)
	h_list.append(h)	
		
for cy in range(101):
	for cx in range(101):
		H_list = []
		for i in range(N):
			if h_list[i] != 0:
				H = abs(cx - x_list[i])+abs(cy - y_list[i])+h_list[i]
				H_list.append(H) 
			if h_list[i] == 0:
				h_mathematical=H_list[0]-abs(cx-x)-abs(cy-y)
				if h_mathematical > 0:
					break
		if len(H_list) == N:
			if all_same(H_list):
				print(str(cx)+' '+str(cy)+' '+str(H_list[0]))
				break		
	else:
		continue
	break

### FIXED CODE ###

N = int(input())

x_list=[]
y_list=[]
h_list=[]


def all_same(items):
	return all(map(lambda x: x == items[0], items))

for i in range(N):
	x,y,h=map(int, input().split())
	x_list.append(x)
	y_list.append(y)
	h_list.append(h)
		
for cy in range(101):
	for cx in range(101):
		n = -1	
		for h in h_list:
			n += 1
			if h >= 1:
				H = abs(cx - x_list[n])+abs(cy - y_list[n])+h
				h_now_list=[]
				break
		for i in range(N):
			h_now = max((H-abs(cx - x_list[i])-abs(cy - y_list[i])), 0)
			h_now_list.append(h_now)
			if h_now != h_list[i]:
				break	
			else:
				if len(h_now_list)==N:
					print(str(cx)+' '+str(cy)+' '+str(H))
					break
	else:
		continue
	break
S = input()
U = ['dreamer', 'dream', 'eraser', 'erase']

answer = 'NO'


def possible(current):
    possible = []
    for string in U:
        if S.startswith(current + string):
            possible.append(string)
    return possible


def judge(current):
    if current == S:
        global answer
        answer = 'YES'
        return
    if answer == 'YES':
        return
    else:
        if possible(current) == []:
            return
        else:
            for candidate in possible(current):
                new = current + candidate
                if len(S) >= len(new):
                    judge(current + candidate)


judge('')

print(answer)

### FIXED CODE ###

S = input()
T = ''
U = ['dreamer', 'dream', 'eraser', 'erase']
answer = 'NO'
list = [T]
done = 0

while done == 0:
    for l in list:
        list.remove(l)
        for u in U:
            if S.startswith(l + u):
                if S == l + u:
                    answer = 'YES'
                    done = 1
                list.append(l + u)
    if list == []:
        done = 1
print(answer)
b = input().split()
    a = list(map(int, input().split()))
    c = {b[i]:a[i] for i in range(len(b))}
    print(c[input()] - 1)

### FIXED CODE ###

s, t = input().split()
a, b = map(int, input().split())
i = input()
if t == i:
  print(a, b-1)
else:
  print(a-1, b)
n = int(input())
str_list = input().split()

list = [int(k) for k in str_list]

list.sort(reverse=True)

result = 1

if(0 in list):
  print('0')
  return

for i in range(n):
  result = result * list[i]
  if(result >= 1000000000000000000):
    print('-1')
    return

print(result)
  


### FIXED CODE ###

n = int(input())
str_list = input().split()

list = [int(k) for k in str_list]

list.sort(reverse=True)

result = 1

if(0 in list):
  print('0')
  exit()

for i in range(n):
  result = result * list[i]
  if(result > 1000000000000000000):
    print('-1')
    exit()

print(result)
S=input().split()
A=sorted(S)
print(S[2]-S[0])


### FIXED CODE ###

S=list(map(int,input().split()))
A=sorted(S)

print(A[2]-A[0])
# 期待値
def func_d(n):
    if n == 1:
        return 1
    else:
        return n + func_d(n-1)

N, K = [int(i) for i in input().split()]
P = [func_d(int(i))/int(i) for i in input().split()]

# 累積和
A = [0]
for i in range(0, N):
    A.append(P[i]+A[i])

ans = []
for i in range(K, N+1):
    ans.append(A[i] - A[i-K])
    
print(max(ans))

### FIXED CODE ###

def func(x):
    return (x+1)/2
N, K = [int(i) for i in input().split()]
P = [func(int(i)) for i in input().split()]

# 累積和
A = [0]
for i in P:
    A.append(A[-1]+i)

ans = []
for i in range(K, N+1):
    ans.append(A[i] - A[i-K])
    
print(max(ans))
n, gap = int(input()), []
data = list(map(int, [input() for i in range(n)]))
cnt, g = 0, 0
while g <= n//9:
    g = 3 * g + 1
    gap.append(g)
m = len(gap)
gap = gap[::-1]
for i in gap:
    for idx in range(i, n):
        j = idx - i
        while j >= 0 and data[j] > data[j+i]:
            data[j+i], data[j] = data[j], data[j+i]
            j -= i
            cnt += 1
print(m)
print(" ".join(map(str, gap)))
print(cnt)
for i in range(n):
    print(data[i])



### FIXED CODE ###

import sys

def shellSort(data, cnt, g, n):
    for idx in range(g, n):
        j = idx - g
        v = data[idx]
        while j >= 0 and data[j] > v:
            data[j+g] = data[j]
            j -= g
            cnt += 1
        data[j+g] = v
    return data, cnt

n, gap = int(input()), []
a = ([int(i) for i in sys.stdin.readlines()], 0)
g = 0
while g <= n//9:
    g = 3 * g + 1
    gap.append(g)
m = len(gap)
for i in gap[::-1]:
    a = shellSort(a[0], a[1], i, n)
print(m)
print(" ".join(map(str, gap[::-1])))
print(a[1])
for i in range(n):
    print(a[0][i])
import copy

N=int(input())

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

#print(A)

mama=dict()
papa=dict()
papa[0]=0
papa[1]=0
papa[2]=1
for i in range(3,N/2):
    papa[i]=int(i*papa[i-1]/2)
for i in range(N):

    if(A[i] in mama):
        print(mama[A[i]])
        continue
    
    AA=copy.deepcopy(A)
    ai=A[i]
    del AA[i]
    #print(AA)
    Aset=set(AA)
    count=0
    
    for i in Aset:
        aa=AA.count(i)
        if(aa in papa):
            count+=papa[aa]
            continue
        #print(i,aa)
        aiu=int((aa*(aa-1))/2)
        count+=aiu
        papa[aa]=aiu
    print(count)
    mama[ai]=count


### FIXED CODE ###

from collections import Counter
N=int(input())
A=list(map(int,input().split()))

parent=dict()
An=set(A)
parecou=0
aaa=Counter(A)
for i in aaa.values():
    parecou+=int((i*(i-1)/2))
"""
for i in An:
    f=A.count(i)
    parent[i]=f
    parecou+=int((f*(f-1)/2))
"""


#print(parecou)
for i in range(N):
    anko=aaa[A[i]]
    print(parecou-int((anko*(anko-1)/2))+int(((anko-2)*(anko-1)/2)))
    #print(parecou-anko+1)
/Users/a13937/Documents/workplace/atcoder-practice/venv/bin/python /Users/a13937/Documents/workplace/atcoder-practice/src/main/scala/abc075/C.py
6 5
1 2
2 3
3 4
4 5
5 6
5

Process finished with exit code 0


### FIXED CODE ###

import collections
import queue
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N, M = map(int, input().split())
X, Y = [0] * M, [0] * M
g = [[] for _ in range(N)]

for i in range(M):
    X[i], Y[i] = map(int, input().split())

    X[i] -= 1
    Y[i] -= 1
    g[X[i]].append(Y[i])
    g[Y[i]].append(X[i])


def bfs(x, y):
    visited = [False] * N
    q = queue.Queue()
    for nx in g[x]:
        if nx == y:
            continue
        q.put(nx)
        visited[nx] = True

    visited[x] = True

    while not q.empty():
        cur = q.get()
        if cur == y:
            return True

        for nx in g[cur]:
            if visited[nx]:
                continue
            q.put(nx)
            visited[nx] = True

    return False


cnt = 0
for i in range(M):
    if not bfs(X[i], Y[i]):
        cnt += 1

print(cnt)
# N,Aを入力
N = int(input)
A = int(input)
if (N % 500) > A:# Nを500で割った余りがAより大きいとき
  	print('No')
else: # Nを500で割った余りがAと等しいまたはAより小さいとき
  	print('Yes')
  

### FIXED CODE ###

N = int(input())
A = int(input())
if (N % 500) > A:
  print('No')
else:
  print('Yes')
#5
#1 3 5 4 2
#2
N=int(input())
num=list(map(int,input().split()))
cnt=0
for i in range(N-2):
  if li[i]<li[i+1]<li[i+2] or li[i+2]<li[i+1]<li[i]:
    cnt+=1
print(cnt)    
    

### FIXED CODE ###

#5
#1 3 5 4 2
#2
N=int(input())
li=list(map(int,input().split()))
cnt=0
for i in range(N-2):
  if li[i]<li[i+1]<li[i+2] or li[i+2]<li[i+1]<li[i]:
    cnt+=1
print(cnt)
import numpy as np
N = int(input())
print((a % 2).mean())

### FIXED CODE ###

import numpy as np
N = int(input())
a = np.arange(1, N+1)
print((a % 2).mean())
n = int(input())
#桁が奇数の時の個数
for i in range(1,n+1):
    if len(str(i)) % 2 == 1:
        ans += 1
print(ans)


### FIXED CODE ###

n = int(input())
ans = 0
for i in range(1,n+1):
    if len(str(i)) % 2 == 1:
        ans += 1
print(ans)
from collections import defaultdict
n,m = map(int,input().split())
graph = defaultdict(list)
for i in range(m):
    a,b = map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)

ans = [None]*(n-1)
check = [i for i in range(2,n+1)]
tmp = []
for j in graph[1]:
    ans[j-2] = 1
    check.remove(j)
    tmp.append(j)

while check != []:
    new_tmp = []
    for i in tmp:
        for j in graph[i]:
            if ans[j-2] == None and j != 1:
                ans[j-2] = i
                check.remove(j)
                new_tmp.append(j)
    tmp = new_tmp
print(ans)

### FIXED CODE ###

from collections import defaultdict
n,m = map(int,input().split())
graph = defaultdict(list)
for i in range(m):
    a,b = map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)

ans = defaultdict(int)
next_list = []
for j in graph[1]:
    ans[j] = 1
    next_list.append(j)

target_list = next_list[:]
while True:
    next_list = []
    if len(target_list) == 0:
        break

    for i in target_list:
        for j in graph[i]:
            if j not in ans:
                ans[j] = i
                next_list.append(j)
    target_list = next_list[:]


print('Yes')
for i in range(2,n+1):
    print(ans[i])
from sys import stdin

k = int(stdin.readline().rstrip())
s = int(stdin.readline().rstrip())
count = 0

x = 0
y = 0
z = 0

for x in range(s+1):
    y = 0
    for y in range(s+1):
        z = 0
        if x + y + z <= k:
            z = s - x - y
            count +=1
            #print(x,y,z)

print(count,flush=True)

### FIXED CODE ###

from sys import stdin
lis =[]
#k = int(stdin.readline().rstrip())
lis= stdin.readline().rstrip().split()
k = int(lis[0])
s = int(lis[1])
count = 0
x = 0
y = 0
z = 0
for x in range(k+1):
    y = 0
    for y in range(k+1):
        z = 0
        z = s - x - y
        if z <= k and z >= 0:
                count +=1



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

b = []
s = int(sum(a)/len(a))
for i in range(len(a)):
    b.append(abs(a[i]-s)

print(b.index(min(b)))


### FIXED CODE ###

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

b = []
s = (sum(a)/len(a))
for i in range(len(a)):
    b.append(abs(a[i]-s))

print(b.index(min(b)))
from math import abs
N = int(input())

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

total_list = [0] * N
for i in range(N):
    list_one = weight_list[: i + 1]
    list_two = weight_list[i + 1:]
    
    abs_diff = math.abs(sum(list_one) - sum(list_two))
    
    total_list[i] = abs_diff
print(min(total_list))

### FIXED CODE ###

from math import fabs
N = int(input())

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

total_list = [0] * N
for i in range(N):
    list_one = weight_list[: i + 1]
    list_two = weight_list[i + 1:]
    
    abs_diff = fabs(sum(list_one) - sum(list_two))
    
    total_list[i] = abs_diff
print(int(min(total_list)))
n,m = int(input().split())
a = int(input().split())
if sum(a)>n:
  print('-1')
else:
  print(n-sum(a))

### FIXED CODE ###

n,m = map(int,input().split())
a = list(map(int,input().split()))
if sum(a)>n:
  print('-1')
else:
  print(n-sum(a))