Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**9)

TO_K = []
TREE = []
DISTANCE = []

def dfs(child, parent):
    for i_node in TREE[parent]:
        if i_node[0] == child:
            TO_K[child] = TO_K[parent] + i_node[1]

    for i_gch in TREE[child]:
        if i_gch[0] == parent:
            TO_K[child] = TO_K[parent] + i_gch[1]
        else:
            dfs(i_gch[0], child)

    return


def main():
    n = int(input())
    abc = [[int(_) for _ in input().split()] for i in range(n-1)]
    q, k = map(int, input().split())
    xy = [[int(_) for _ in input().split()] for i in range(q)]

    global TO_K
    # index '0' is not used.
    TO_K = [0]*(n+1)

    global TREE
    # index '0' is not used.
    TREE = [[] for _ in range(n+1)]
    for a, b, c in abc:
        TREE[a].append([b, c])
        TREE[b].append([a, c])

    dfs(k, 0)

    for x, y in xy:
        print(TO_K[x]+TO_K[y])
    return


if __name__ == "__main__":
    main()
    sys.exit(0)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)

TO_K = []
TREE = []

def dfs(parent, distance):
    for i_node in TREE[parent]:
        child, dd = i_node
        if TO_K[child] != -1:
            continue

        next_dt = distance + dd
        TO_K[child] = next_dt
        dfs(child, next_dt)

    return


def main():
    n = int(input())
    abc = [[int(_) for _ in input().split()] for i in range(n-1)]
    q, k = map(int, input().split())
    xy = [[int(_) for _ in input().split()] for i in range(q)]

    global TO_K
    # index '0' is not used.
    TO_K = [-1]*(n+1)

    global TREE
    # index '0' is not used.
    TREE = [[] for _ in range(n+1)]
    for a, b, c in abc:
        TREE[a].append([b, c])
        TREE[b].append([a, c])

    TO_K[k] = 0
    dfs(k, 0)

    for x, y in xy:
        print(TO_K[x]+TO_K[y])
    return


if __name__ == "__main__":
    main()
    sys.exit(0)
### BUGGY CODE ###

N,K = map(int,input().split())
tmp=[]
for i in range(N):
    a_i,b_i=map(int,input().split())
    tmp += [a_i]*b_i

tmp.sort()
print(tmp[K-1])

### FIXED CODE ###

N,K = map(int,input().split())
tmp=[]
for i in range(N):
    a_i,b_i=map(int,input().split())
    tmp.append([a_i,b_i])

tmp.sort(key=lambda x:x[0])
for t in tmp:
    K -= t[1]
    if K<=0:
        print(t[0])
        break
### BUGGY CODE ###

N = int(input())
C = []
for i in range(N):
    C.append("".join(sorted(input())))
B = set(C)
ans = 0
for j in B:
    t = C.count(j)
    if t > 1:
        ans += int(t*(t-1)/2 )
# 1->0, 2->1, 3->3, 4->6, 5->10 :: nC2
    
print(ans)

### FIXED CODE ###

N=int(input())
dictionary={}
count=0
for i in range(N):
    s="".join(sorted(input()))
    if s in dictionary:
        dictionary[s]+=1
        count+=dictionary[s]
    else:
        dictionary[s]=0
print(count)
### BUGGY CODE ###

N, K = map(int,input().split())
ls_pass = [0]+list(map(int,input().split()))
a=1
b=0
c=0
d=0
ls_past=[1]
ls_cicle=[]
for i in range(1,N*3):
  b=a
  a=ls_pass[a]
  if b==a:
    print(a)
    break
  elif a in ls_past:
    if c==0:
      c=i
      d=a
      ls_cicle.append(d)
      continue
    elif a==d:
      print(ls_cicle[(K-c)%(i-c)])
      break
    else:
      ls_cicle.append(a)
  elif i==K:
    print(a)
    break  
  else:
    ls_past.append(a)

### FIXED CODE ###

N, K = map(int,input().split())
ls_pass = [0]+list(map(int,input().split()))
a=1
b=0

ls=["ンゴ"]+[0]+["ンゴ"]*(N-1)
ls_past=[1]
for i in range(1,N*3):
  b=a
  a=ls_pass[a]
  if ls[a]!="ンゴ":
    ls_cicle=ls_past[ls[a]:i]
    print(ls_cicle[(K-i)%len(ls_cicle)])
    break
  elif i==K:
    print(a)
    break  
  else:
    ls_past.append(a)
    ls[a]=i
### BUGGY CODE ###

def slove():
    import sys
    input = sys.stdin.readline
    n, m, l = list(map(int, input().rstrip('\n').split()))
    INF = 10 ** 11
    w = [[INF] * n for _ in range(n)]
    wl = [[INF] * n for _ in range(n)]

    for i in range(n):
        w[i][i] = 0

    for i in range(m):
        a, b, c = list(map(int, input().rstrip('\n').split()))
        if c <= l:
            w[a - 1][b - 1] = c
            w[b - 1][a - 1] = c

    for i in range(n):
        for j in range(n):
            for k in range(n):
                w[j][k] = min(w[j][k], w[j][i] + w[i][k])

    for i in range(n):
        for j in range(n):
            if w[i][j] <= l:
                wl[i][j] = 1
    for i in range(n):
        for j in range(n):
            for k in range(n):
                wl[j][k] = min(wl[j][k], wl[j][i] + wl[i][k])

    q = int(input().rstrip('\n'))
    for i in range(q):
        s, t = list(map(int, input().rstrip('\n').split()))
        if wl[s-1][t-1] == INF:
            print(-1)
        else:
            print(wl[s-1][t-1] - 1)


if __name__ == '__main__':
    slove()


### FIXED CODE ###

def slove():
    import sys
    input = sys.stdin.readline
    n, m, l = list(map(int, input().rstrip('\n').split()))
    INF = 10 ** 11
    w = [[INF] * n for _ in range(n)]
    wl = [[INF] * n for _ in range(n)]

    for i in range(n):
        w[i][i] = 0

    for i in range(m):
        a, b, c = list(map(int, input().rstrip('\n').split()))
        if c <= l:
            w[a - 1][b - 1] = c
            w[b - 1][a - 1] = c

    for i in range(n):
        for j in range(n):
            for k in range(n):
                w[j][k] = min(w[j][k], w[j][i] + w[i][k])

    for i in range(n):
        for j in range(n):
            if w[i][j] <= l:
                wl[i][j] = 1
    for i in range(n):
        for j in range(n):
            for k in range(n):
                wl[j][k] = min(wl[j][k], wl[j][i] + wl[i][k])

    q = int(input().rstrip('\n'))
    for i in range(q):
        s, t = list(map(int, input().rstrip('\n').split()))
        if wl[s-1][t-1] == INF:
            print(-1)
        else:
            print(wl[s-1][t-1] - 1)


if __name__ == '__main__':
    slove()
### BUGGY CODE ###

from collections import deque

def main():
    n = input()
    A = map(int,raw_input().split())
    q = input()
    M = map(int,raw_input().split())

    for m in M:
        w = sub(m,n,A)
        print w
        
def sub(m,n,A):
    qA = deque(A)
    for j in range(n):
        w = rec(m,qA)
        if w:
            break
        qA.popleft()            
    if w:
        return "yes"
    else:
        return "no"
    
def rec(m,A):
    Ac = deque(list(A)[:])
    Ad = deque(list(A)[:])
    r1 = rec1(m,Ac)
    r2 = rec1(m-A[0],Ad)

    if r1 or r2:
        return True
    else:
        return False

def rec1(m_new,A):
    #print A
    if m_new == 0:
        return True
    elif m_new < 0:
        return False
    else:
        if len(A) == 1:
            return False
        else:
            A.popleft()
            return rec(m_new,A)
    

if __name__ == "__main__":
    main()

### FIXED CODE ###

from collections import deque

def main():
    n = input()
    A = deque(map(int,raw_input().split()))
    q = input()
    M = map(int,raw_input().split())

    p = rec([0],A)

    for m in M:
        if m in p:
            print "yes"
        else:
            print "no"

def rec(a,A):
    if len(A) == 0:
        return a
    else:
        y = A.popleft()
        a = a+[x+y for x in a]
        return rec(a,A)

if __name__ == "__main__":
    main()
### BUGGY CODE ###

n = int(input())
res = 1
for i in range(1,n+1):
    res*=i
print(res%(10**9+7))

### FIXED CODE ###

import math

n = int(input())

print(math.factorial(n)%(10**9+7))
### BUGGY CODE ###

import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

X,Y,Z,K = IL()
A = IL()
B = IL()
C = IL() 

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

ab = []
for i in list(itertools.product(A,B)):
    ab.append(sum(i))

ab.sort(reverse=True)

ans = []
for i in list(itertools.product(ab[:3000],C)):
    ans.append(sum(i))

ans.sort(reverse=True)

for i in range(K):
    print(ans[i])

### FIXED CODE ###

import itertools
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

X,Y,Z,K = IL()
a = IL()
b = IL()
c = IL()

ab = []
for i in itertools.product(a,b):
  ab.append(sum(i))
ab.sort(reverse=True)

ans = []
for i in itertools.product(ab[:3000],c):
  ans.append(sum(i))
ans.sort(reverse=True)

for i in range(K):
  print(ans[i])
### BUGGY CODE ###

from collections import deque

DIRECTIONS = [(0, 1), (1, 0), (0, -1), (-1, 0)]


def count(start, S, H, W):
    retval = 0
    q = deque()
    q.append((start[0], start[1], "#"))
    tested = [[False] * W for _ in range(H)]
    while(len(q)):
        i, j, color = q.popleft()
        if tested[i][j]:
            continue
        tested[i][j] = True
        if color == ".":
            retval += 1
        if color == "#":
            ncolor = "."
        else:
            ncolor = "#"
        for d in DIRECTIONS:
            ni = i + d[0]
            nj = j + d[1]
            if 0 <= ni and ni < H and 0 <= nj and nj < W and S[ni][nj] == ncolor:
                q.append((ni, nj, ncolor))
    return retval


def main():
    H, W = map(int, input().split())
    S = [input() for _ in range(H)]
    retval = 0
    for i in range(H):
        for j in range(W):
            if(S[i][j] == "#"):
                retval += count((i, j), S, H, W)
    print(retval)


if __name__ == "__main__":
    main()


### FIXED CODE ###

from collections import deque

DIRECTIONS = [(0, 1), (1, 0), (0, -1), (-1, 0)]


def count(start, S, H, W, tested):
    if tested[start[0]][start[1]]:
        return 0
    q = deque()
    q.append((start[0], start[1], "#"))
    white = 0
    black = 0
    while(len(q)):
        i, j, color = q.popleft()
        if tested[i][j]:
            continue
        tested[i][j] = True
        if color == ".":
            white += 1
            ncolor = "#"
        else:  # color == "#":
            black += 1
            ncolor = "."
        for d in DIRECTIONS:
            ni = i + d[0]
            nj = j + d[1]
            if 0 <= ni and ni < H and 0 <= nj and nj < W and S[ni][nj] == ncolor:
                q.append((ni, nj, ncolor))
    return black * white


def main():
    H, W = map(int, input().split())
    S = [input() for _ in range(H)]
    tested = [[False] * W for _ in range(H)]
    retval = 0
    for i in range(H):
        for j in range(W):
            if(S[i][j] == "#"):
                retval += count((i, j), S, H, W, tested)
    print(retval)


if __name__ == "__main__":
    main()
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)

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

INF = 10**18
dp = [[INF] * N for _ in range(N)]
flag = [[False] * N for _ in range(N)]

def calc(i, j):
    if flag[i][j]:
        return dp[i][j]
    flag[i][j] = True
    if i == j:
        dp[i][j] = a[i]
    else:
        dp[i][j] = max(a[i] - calc(i+1, j), a[j] - calc(i, j-1))
    return dp[i][j]

print(calc(0, N-1))

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)

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

INF = 10**18
dp = [[INF] * N for _ in range(N)]

# def calc(i, j, t):
#     if dp[i][j] != INF:
#         return dp[i][j]
#     if t == 0:
#         if i == j:
#             dp[i][j] = a[i]
#         else:
#             dp[i][j] = max(calc(i+1, j, 1) + a[i], calc(i, j-1, 1) + a[j])
#     else:
#         if i == j:
#             dp[i][j] = -a[i]
#         else:
#             dp[i][j] = min(calc(i+1, j, 0) - a[i], calc(i, j-1, 0) - a[j])
#     return dp[i][j]

# print(calc(0, N-1, 0))

for l in range(N):
    t = (N-l) % 2
    for i in range(N-l):
        j = i + l
        if t == 1:
            if l == 0:
                dp[i][j] = a[i]
            else:
                dp[i][j] = max(dp[i+1][j] + a[i], dp[i][j-1] + a[j])
        else:
            if l == 0:
                dp[i][j] = -a[i]
            else:
                dp[i][j] = min(dp[i+1][j] - a[i], dp[i][j-1] - a[j])
print(dp[0][N-1])
### BUGGY CODE ###

n = int(input())

count = -1

for i in range(int(n/2)):
    for j in range(n-1):
        if (i+1)*(j+1) < n:
            count += 1
        else:
            break
count += n - int(n/2)
print(count)


### FIXED CODE ###

n = int(input())

count = 0

if n%2==0:
    for i in range(int(n/2)-1):
        count += int((n-1)/(i+1))
    count += int(n/2)

else:
    for i in range(int(n/2)):
        count += int((n-1)/(i+1))
    count += int(n/2)

print(count)
### BUGGY CODE ###

s = input()
K = int(input())
l = len(s)
s2 = list(set(list(s)))
s2.sort()

dic = {}
flg = False
for i in range(len(s2)):
	for j in range(l):
		if s[j] == s2[i]:
			for k in range(1,l-j+1):
				a = s[j:j+k]
				if not a in dic:
					if K == 1:
						flg = True			
					K -= 1
					dic[a] = 1

	if flg:
		break
k = list(dic.keys())
k.sort()
print(k[K-1])

### FIXED CODE ###

s = input()
K = int(input())
l = len(s)
dic = {}
for i in range(l):
	if not s[i] in dic:
		dic[s[i]] = []
	for j in range(1,6):
		if i + j > (l):
			break
		else:
			dic[s[i]].append(s[i:i+j])

lst = list(dic.keys())
lst.sort()
for c in lst:
	dic[c] = sorted(set(dic[c]))
	l = len(dic[c])
	if K > l:
		K -= l
	else:
		print(dic[c][K-1])
		exit(0)
### BUGGY CODE ###

n = int(input())
X = tuple(map(int,input().split()))
for i in range(n):
    b = list(X)
    del b[i]
    b.sort()
    print(b[int(n/2-1)])

### FIXED CODE ###

import bisect
n = int(input())
X = tuple(map(int,input().split()))
Xs = list(X)
Xs.sort()
for x in X:
    a = bisect.bisect_left(Xs,x)
    if a >= n/2:
        print(Xs[int(n/2)-1])
    else:
        print(Xs[int(n/2)])
### BUGGY CODE ###

def main():
    N = int(input())
    csf = []
    for _ in range(N - 1):
        C, S, F = map(int, input().split())
        csf.append((C, S, F))
    
    ans = []
    for i in range(N - 1):
        c, s, _  = csf[i]
        t = c + s
        for ii in range(i + 1, N - 1):
            nc, ns, nf = csf[ii]
            while t > ns:
                ns += nf
            t += nc + ns - t
        ans.append(t)
    ans.append(0)
    
    for t in ans:
        print(t)
    

main()


### FIXED CODE ###

def main():
    N = int(input())
    csf = []
    for _ in range(N - 1):
        C, S, F = map(int, input().split())
        csf.append((C, S, F))
    
    ans = []
    for i in range(N - 1):
        c, s, _  = csf[i]
        t = c + s
        for ii in range(i + 1, N - 1):
            nc, ns, nf = csf[ii]
            if t > ns:
                if (t - ns) % nf == 0:
                    ns += ((t - ns) // nf) * nf
                else:
                    ns += ((t - ns) // nf + 1) * nf
            t += nc + ns - t
        ans.append(t)
    ans.append(0)
    
    for t in ans:
        print(t)
    

main()
### BUGGY CODE ###

import numpy as np
N,K = map(int, input().split())

A_list = np.array([0]+list(map(int, input().split())))
#print(A_np)

for j in range(K):
  new_A=np.array([0]*(N+1))
  for i in range(1,N+1):
    #print(A_np)
    mi=i-A_list[i]
    ma=i+A_list[i]
    if mi<0:
      mi=0
    if ma>N:
      ma=N
    new_A[mi:ma+1]+=1
  A_list=new_A
  if sum(A_list[1:N+1])==N*N:
    break
    
for i in range(1,N+1):
  print(A_list[i],end=" ")


### FIXED CODE ###

import numpy as np
from numba import njit

N,K = map(int, input().split())

A_list = np.array([0]+list(map(int, input().split())))

@njit
def update(A_list):

  for j in range(min(K,46)):
    new_A=np.zeros(N+2,dtype=np.int64)
    for i in range(1,N+1):
      #print(new_A)
      mi=i-A_list[i]
      ma=i+A_list[i]
      if mi<0:
        mi=0
      if ma>N:
        ma=N
      #new_A[mi:ma+1]+=1
      new_A[mi]+=1
      new_A[ma+1]-=1

    A_list=np.cumsum(new_A)
    #if sum(A_list[1:N+1])==N*N:
    #  return(A_list)    
    #  break
      
  return(A_list)

A_list=update(A_list)
for i in range(1,N+1):
  print(A_list[i],end=" ")
### BUGGY CODE ###

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

for i in range(n):
    y = x.copy()
    del y[i]
    print(sorted(y)[n//2 -1])

### FIXED CODE ###

n = int(input())
x = list(map(int, input().split()))
y = sorted(x)
a = y[n//2 - 1]
b = y[n//2]

for i in range(n):
    if x[i] >= b:
        print(a)
    else:
        print(b)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

#input
N, M = map(int, input().split())
s = [0] * M
t = [0] * M
for i in range(M):
    s[i], t[i] = map(int, input().split())

#output
#（便宜的に地点から-1としておく）
u = [[]] * N
for v in s:
    u[v-1] = [t-1 for i, t in enumerate(t) if s[i] == v]

#地点vにたどり着く確率をp[v]とする。
p = [0] * N
p[0] = 1
for v in range(N):
    for i in range(v):
        if v in u[i]:
            p[v] += p[i]/len(u[i])

#期待値をゴールから逆順に求めていく。点vからゴールまでの移動距離の期待値をq[v]とする。
q = [0] * N
q[N-1] = 0
for v in reversed(range(N)):
    for i in u[v]:
        q[v] += (1 + q[i])/len(u[v])

v = [0] * M
for i in range(M):
    if len(u[(s[i]-1)]) > 1:
        v[i] = p[(s[i]-1)]*(q[(s[i]-1)]/(len(u[(s[i]-1)])-1) - (1 + q[(t[i]-1)])/(len(u[(s[i]-1)])-1))

print(q[0]+min(v))

### FIXED CODE ###

import sys
input = sys.stdin.readline

#input
N, M = map(int, input().split())
u = [[] for i in range(N-1)]
#（便宜的に地点から-1としておく）
for i in range(M):
    s, t = map(int, input().split())
    u[s-1].append(t-1)

#output
#地点vにたどり着く確率をp[v]とする。
p = [0] * N
p[0] = 1
for x, y in enumerate(u):
    for z in y:
        p[z] += p[x]/len(y)

#期待値をゴールから逆順に求めていく。点vからゴールまでの移動距離の期待値をq[v]とする。
q = [0] * N
q[N-1] = 0
for x, y in list(enumerate(u))[::-1]:
    q[x] = sum(q[z] for z in y)/len(y) + 1

v = [0] * N
for i in range(N-1):
    a = len(u[i])
    if a > 1:
        b = max(q[c] for c in u[i])
        v[i] = p[i]*(q[i] - (1+b))/(a-1)

print(q[0]+min(v))
### BUGGY CODE ###

import sys
inputs = sys.stdin.readline
N, Q= map(int,inputs().split())
V = [None]*N
E = []
for n in range(N):
	V[n] = list(map(int,inputs().split()))
	V[n][0] -= V[n][2]
	V[n][1] -= V[n][2]
	E.append([V[n][0],1,V[n][2]])
	E.append([V[n][1],-1,V[n][2]])
D = [int(inputs()) for p in [0]*Q]
E.sort(key = lambda x:x[0])
mini = 1000000001
kouho = [1000000001]
q = 0
d = D[0]
flag = False
for e in E:
	cont = False
	mini = 1000000001
	while(e[0] > d):
		if cont == True:
			if mini < 1000000001:
				print(mini)
			else:
				print(-1)
		else:
			for k in kouho:
				mini = min(k,mini)
			if mini < 1000000001:
				print(mini)
			else:
				print(-1)
		cont = True
		if q < Q-1:
			q = q + 1
			d = D[q]
		else:
			flag = True
			q = q + 1
			break
	if flag == True:
		break
	if  e[1] == 1:
		kouho.append(e[2])
	elif e[1] == -1:
		kouho.remove(e[2])
for t in [None]*(Q-q):
	print(-1)

### FIXED CODE ###

import sys
from operator import itemgetter
def main():
	inputs = sys.stdin.readline
	N, Q= map(int,inputs().split())
	E = [None]*2*N
	for n in range(N):
		a,b,c = map(int,inputs().split())
		E[2*n] = (a - c, 1, c)
		E[2*n + 1] = (b - c, -1, c)
	E.sort(key=itemgetter(0))
	tuple(tuple(E))
	mini = 1000000001
	kouho = {1000000001}
	my_add = kouho.add
	my_discard = kouho.discard
	q = 0
	d = int(inputs())
	flag = False
	cont = False
	for e in E:
		while e[0] > d:
			if cont == True:
				print(mini-(mini//1000000001)*1000000002)
			else:
				mini = min(kouho)
				print(mini-(mini//1000000001)*1000000002)
			cont = True
			q = q + 1
			if q > Q-1:
				flag = True
				break
			d = int(inputs())
		if flag == True:
			break
		if e[1] == 1:
			my_add(e[2])
			if mini > e[2]:
				mini = e[2]
		elif e[1] == -1:
			my_discard(e[2])
			if mini == e[2]:
				cont = False
	for t in [None]*(Q-q):
		print(-1)
main()
### BUGGY CODE ###

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

a = []
b = []

for i in range(m):
	s, t = map(int, input().split())
	a.append(s-1)
	b.append(t-1)

#各部屋から行ける部屋
c = [[] for i in range(n)]

for i in range(m):
	c[a[i]].append(b[i])
	c[b[i]].append(a[i])

s = [0]
f = []

#部屋1からの距離
d = [10**6]*n
d[0] = 0

while s!=[]:
	x = s[-1]
	s.pop(-1)
	if not(x in f):
		for i in c[x]:
			if not((i in s) or (i in f)):
				s.append(i)
			d[i] = min(d[i], d[x]+1)
		f.append(x)

print('Yes')
for i in range(1,n):
	m = 10**6
	ans = 0
	for j in c[i]:
		if d[j]<m:
			m = d[j]
			ans = j+1
	print(ans)

### FIXED CODE ###

import queue

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

a = []
b = []

for i in range(m):
	s, t = map(int, input().split())
	a.append(s-1)
	b.append(t-1)

#各部屋から行ける部屋
c = [[] for i in range(n)]

for i in range(m):
	c[a[i]].append(b[i])
	c[b[i]].append(a[i])

q = queue.Queue()
q.put(0)

#部屋1からの距離
inf = 10**8
d = [inf]*n
d[0] = 0
ans = [0]*n

while not q.empty():
	x = q.get()
	for i in c[x]:
		if d[i]==inf:
			q.put(i)
			d[i] = d[x]+1
			ans[i] = x+1

print('Yes')
for i in range(1,n):
	print(ans[i])
### BUGGY CODE ###

N , K = map(int,input().split())
Lum = [a for a in map(int,input().split())]

for i1 in range(min(K,50)):
    B = [0 for i in range(N)]
    for i in range(N):
        for j in range(max(0,i-Lum[i]),min(i+Lum[i]+1,N)):
            B[j]+=1
    Lum = B

Lum = [str(l) for l in Lum]
Lum=" ".join(Lum)
print(Lum)


### FIXED CODE ###

import numpy as np
from numba import jit 
N , K = map(int,input().split())
Lum = np.array(list(map(int,input().split())))

@jit("i8,i8,i8[:]")
def fn(N,K,A):
    K1 = min(K,41)
    for i1 in range(K1):
        B = np.zeros(N,dtype=np.int64)
        for i in range(N):
            l = max(0,i-A[i])
            r = min(N-1,i+A[i])
            B[l]+=1
            if r+1<N:
                B[r+1]-=1
        for i in range(1,N):
            B[i]+=B[i-1]
        A = B
    return A

Lum = list(fn(N,K,Lum))
Lum = [str(l) for l in Lum]
Lum=" ".join(Lum)
print(Lum)
### BUGGY CODE ###

def is_good(mid, key):
    ret = 0
    for i in range(N):
        ret += max(0, A[i] - mid // F[i])
    return ret <= key


def binary_search(key):
    bad, good = -1, 10 ** 18
    while good - bad > 1:
        mid = (bad + good) // 2
        if is_good(mid, key):
            good = mid
        else:
            bad = mid
    return good


N, K = map(int, input().split())
A = sorted(map(int, input().split()))
F = sorted(map(int, input().split()), reverse=True)
print(binary_search(K))


### FIXED CODE ###

def is_good(mid, key):
    ret = 0
    for i in range(N):
        ret += max(0, A[i] - mid // F[i])
    return ret <= key


def binary_search(key):
    bad, good = -1, 10 ** 18
    while good - bad > 1:
        mid = (bad + good) // 2
        if is_good(mid, key):
            good = mid
        else:
            bad = mid
    return good


N, K = map(int, input().split())
A = sorted(map(int, input().split()))
F = sorted(map(int, input().split()), reverse=True)
print(binary_search(K))
### BUGGY CODE ###

import math
y=int(input())
cnt=0
for i in range (1,y+1):
    for k in range(1,y+1):
        for j in range(1,y+1):
            a = [i,j,k]#リスト
            ans = a[0]
            for x in range(len(a)):
                ans = math.gcd(ans, a[x])
            cnt+=ans
print(cnt)

### FIXED CODE ###

import math
y=int(input())
cnt=0
for i in range (1,y+1):
    for k in range(1,y+1):
        for j in range(1,y+1):
            a = [i,j,k]#リスト
            ans = a[0]
            for x in range(len(a)):
                ans = math.gcd(ans, a[x])
            cnt+=ans
print(cnt)
### BUGGY CODE ###

import collections
N = int(input())
S = list(map(int, input()))
dic = dict()

ans = 0

for i in range(N - 2):
	for j in range(i + 1, N - 1):
		if not (S[i], S[j]) in dic:
			dic[(S[i], S[j])] = 1
			ans += len(collections.Counter(S[j + 1:]))

print(ans)

### FIXED CODE ###

import collections
N = int(input())
S = list(map(int, input()))
ans = 0
first = [0 for _ in range(10)]
lst = [[0 for _ in range(10)] for _ in range(10)]

for i in range(N):
	ima = 100
	if first[S[i]] == 0:
		first[S[i]] = 1
		ima = S[i]
	for j in range(10):
		if ima != j and first[j] == 1 and lst[j][S[i]] == 0:
			lst[j][S[i]] = 1
			ans += len(collections.Counter(S[i + 1:]))
				
				
print(ans)