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

import math
Q = int(input())

l = []
r = []
while True:
  try:
    lr=list(map(int,input().split()))
    l.append(lr[0])
    r.append(lr[1])
  except:
    break

def is_prime(num):
  if(type(num) != type(0)):
    print('error at '+str(num)+' type = '+str(type(num)))
    print(type(int))
    return 0
  if(num<2):
    return 0
  elif(num == 2):
    return 1
  n = math.ceil(math.sqrt(num))
  for i in range(2,n+1):
    if((num%i) == 0):
      return 0
  return 1

def create_list():
  MAXI = max(r)+1
  
  prime = [1 for i in range(MAXI)]
  prime[0] = 0
  prime[1] = 0
  for i in range(2,MAXI):
    if(prime[i] == 0):
      continue
    else:
      prime[i] = is_prime(i)
      if(prime[i] == 0):
        for j in range(i,MAXI,i*2):
          prime[j] = 0
        for j in range(i,MAXI,i*3):
          prime[j] = 0
        for j in range(i,MAXI,i*5):
          prime[j] = 0
  sn = [0]
  for i in range(1,MAXI+1,2):
    sn.append(prime[i] * prime[int((i+1)/2)]) #odd
    sn.append(0) #even
  return sn

base = create_list()
for i in range(Q):
  if(l[i]==r[i]):
    print(base[l[i]])
  else:
    lnum = base[0:l[i]]
    rnum = base[0:r[i]]
    print( sum(rnum)-sum(lnum) )

### FIXED CODE ###

import math
import sys
sys.setrecursionlimit(10 ** 5 + 10)

Q = int(input())

l = [0 for _ in range(Q)]
r = [0 for _ in range(Q)]
i = 0
while True:
  try:
    lr=list(map(int,input().split()))
    l[i] = lr[0]
    r[i] = lr[1]
    i+=1
  except:
    break

def is_prime(num):
  #if(type(num) != type(0)):
  #  print('error at '+str(num)+' type = '+str(type(num)))
  #  print(type(int))
  #  return 0
  #if(num<2):
  #  return 0
  if(num == 2):
    return 1
  n = math.ceil(math.sqrt(num))
  for i in range(2,n+1):
    if((num%i) == 0):
      return 0
  return 1

def create_list():
  MAXI = max(r)+1
  
  prime = [1 for _ in range(MAXI+1)]
  prime[0] = 0
  prime[1] = 0
  for i in range(2,MAXI):
    if(prime[i] == 0):
      continue
    else:
      prime[i] = is_prime(i)
      for j in range(i*2,MAXI,i*2):
        prime[j] = 0
      for j in range(i*5,MAXI,i*3):
        prime[j] = 0
      for j in range(i*5,MAXI,i*5):
        prime[j] = 0
  #print(prime)
  sn = [0 for _ in range(MAXI+2)]
  for i in range(1,MAXI+1,2):
    #print('int(('+str(i+1)+')/2) = '+str(int((i+1)/2))+' when '+str(prime[int((i+1)/2)]))
    sn[i] += sn[i-1] + (prime[i] * prime[int((i+1)/2)]) #odd
    sn[i+1] = sn[i]
  return sn

base = create_list()
#print(base)
for i in range(Q):
  print( base[r[i]] - base[l[i]-1] )#sum(rnum)-sum(lnum) )
### BUGGY CODE ###

#!/usr/bin/env python3
import sys


def solve(S: str):
    ct = 0
    for i in range(len(S)):
        for j in range(i, len(S)):
            s = S[i:(j+1)]
            si = int(s)
            if si % 2019 == 0:
                ct += 1
    print(ct)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    # S = int(next(tokens))  # type: int
    S = str(next(tokens))
    solve(S)

if __name__ == '__main__':
    main()

### FIXED CODE ###

#!/usr/bin/env python3
import sys


def solve(S: str):
    T = [0 for _ in range(len(S) + 1)]
    for i in range(len(S) - 1, -1, -1):
        T[i] = (T[i+1] + int(S[i]) * pow(10, len(S) - 1 - i, 2019)) % 2019
    # T = [int(S[i:]) % 2019 if i < len(S) else 0 for i in range(len(S) + 1)]
    M = [0 for _ in range(2019)]
    # M = [T.count(i) for i in range(2019)]
    for t in T:
        M[t] += 1
    ct = 0
    for m in M:
        ct += m * (m - 1) / 2

    print(int(ct))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    # S = int(next(tokens))  # type: int
    S = str(next(tokens))
    solve(S)

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

n = int(input())
a = [input() for i in range(n)] 
ans =1
s = []
s.append(a[0])
for i in a[1:]:
    if i in s:
        continue
    else:
        ans += 1
        s.append(i)


print(ans)    


### FIXED CODE ###

import collections
N=int(input())
S=[]
for i in range(N):
    S.append(input())
s=collections.Counter(S)
s_key=s.keys()
print(len(s_key))
### BUGGY CODE ###

n = int(input())
a = [int(v) for v in input().split()]
ans = 1
num = 1
for i in a:
    if num <= 10 ** 18:
        num *= i
    else:
        num = -1
if num > 10 ** 18:
    num = -1
ans = num
print(ans)


### FIXED CODE ###

n = int(input())
a = [int(v) for v in input().split()]
limit = 1000000000000000000
if 0 in a:
    print (0)
else:
    ans = 1
    num = 1
    for i in a:
        num *= i
        if num > limit:
            num = -1
            break
    ans = num
    print(ans)
### BUGGY CODE ###

import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n = INT()
l = 0
r = n - 1
print(l)
ltmp = STR() #初期状態 偶数席
print(r)
rtmp = STR() #最終状態 奇数
while l < r:
    c = (l + r) // 2
    print(c)
    tmp = STR()
    if tmp == 'Vacant':
        exit()
    if c % 2 == l % 2:
        if tmp == ltmp:
            l = c + 1
        else:
            r = c - 1
    else:
        if tmp == ltmp:
            r = c - 1
        else:
            l = c + 1

### FIXED CODE ###

import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n = INT()
l = 0
r = n - 1
print(l, flush=True)
ltmp = STR()
if ltmp == 'Vacant':
    exit()
print(r, flush=True)
rtmp = STR()
if rtmp == 'Vacant':
    exit()
for i in range(2, 20):
    c = (l + r) // 2
    print(c, flush=True)
    tmp = STR()
    if tmp == 'Vacant':
        exit()
    if c % 2 == l % 2:
        if tmp == ltmp:
            l = c
            ltmp = tmp
        else:
            r = c
    else:
        if tmp == ltmp:
            r = c
        else:
            l = c
            ltmp = tmp
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n):
    left,right=i,i
    now=[0]*20#2^20なので
    for j in range(20):
        if (a[left]>>j)&1:
            now[j]=1
    #print(now)
    while all([now[j]<=1 for j in range(20)]):
        #print(100000000)
        right+=1
        if right==n:
            break
        for k in range(20):
            if (a[right]>>k)&1:
                now[k]+=1
    ans+=(right-left)
    #print(left,right)
print(ans)

### FIXED CODE ###

#しゃくとり法忘れてた
n=int(input())
a=list(map(int,input().split()))
ans=0
right=0
now=[0]*20#2^20なので
for i in range(n):
    left=i
    if i!=0:
        for j in range(20):
            if (a[left-1]>>j)&1:
                now[j]-=1
    else:
        for j in range(20):
            if (a[left]>>j)&1:
                now[j]+=1
    while all([now[j]<=1 for j in range(20)]):
        #print(100000000)
        right+=1
        if right==n:
            break
        for k in range(20):
            if (a[right]>>k)&1:
                now[k]+=1
    else:
        #print(right)
        for k in range(20):
            if (a[right]>>k)&1:
                now[k]-=1
    right-=1
    ans+=(right-left+1)
    #print(left,right)
print(ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**8)

def dfs(v):
  for u in g[v]:
    if checked[u]==1:
      continue
    checked[u]=1
    cnt[u]+=cnt[v]
    dfs(u)

n,q=map(int,input().split())
cnt=[0]*(n+1)
g=[[] for _ in range(n+1)]
for _ in range(n-1):
  a,b=map(int,input().split())
  g[a].append(b)
  g[b].append(a)
for _ in range(q):
  v,val=map(int,input().split())
  cnt[v]+=val
checked=[0]*(n+1)
checked[1]=1
dfs(1)
print(*cnt[1:])

### FIXED CODE ###

import collections

n,q=map(int,input().split())
cnt=[0]*(n+1)
g=[[] for _ in range(n+1)]
for _ in range(n-1):
  a,b=map(int,input().split())
  g[a].append(b)
  g[b].append(a)
for _ in range(q):
  v,val=map(int,input().split())
  cnt[v]+=val
q=collections.deque()
q.append(1)
checked=[0]*(n+1)
while q:
  v=q.pop()
  checked[v]=1
  for u in g[v]:
    if checked[u]==1:
      continue
    cnt[u]+=cnt[v]
    q.append(u)
print(*cnt[1:])
### BUGGY CODE ###

k, s = map(int, input().split())
cnt = 0
for i in range(k+1):
  if i <= s:
    for j in range(k+1):
      if i + j <= s:
        for l in range(k+1):
          if i + j + l == s:
            cnt += 1
print(cnt)

### FIXED CODE ###

def main():
  k, s = map(int, input().split())
  cnt = 0
  for i in range(k+1):
    for j in range(k+1):
      if 0 <= s - i - j <= k:
        cnt += 1
  print(cnt)

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

import sys
inf=1000002
sys.setrecursionlimit(inf)
from collections import deque
h,w,k=map(int,input().split())
x1,y1,x2,y2=map(int,input().split())
c=[input() for i in range(h)]
dp=[[inf if c[i][j]=="." else -1 for j in range(w)] for i in range(h)]
now=deque([[x1-1,y1-1]])
dp[x1-1][y1-1]=0
def bfs(d):
    global dp,now
    l=len(now)
    if l==0:
        return
    dp_sub=deque()
    cand=set()
    for i in range(l):
        x,y=now.popleft()
        for j in range(1,min(k+1,w-y)):
            if dp[x][y+j]==inf:
                dp_sub+=[[x,y+j,d]]
                cand.add((x,y+j))
            else:
                break
        for j in range(1,min(k+1,y+1)):
            if dp[x][y-j]==inf:
                dp_sub+=[[x,y-j,d]]
                cand.add((x,y-j))
            else:
                break
        for j in range(1,min(k+1,h-x)):
            if dp[x+j][y]==inf:
                dp_sub+=[[x+j,y,d]]
                cand.add((x+j,y))
            else:
                break
        for j in range(1,min(k+1,x+1)):
            if dp[x-j][y]==inf:
                dp_sub+=[[x-j,y,d]]
                cand.add((x-j,y))
            else:
                break
    while dp_sub!=deque([]):
        e=dp_sub.popleft()
        dp[e[0]][e[1]]=e[2]
    for i in cand:
        now+=[i]
    bfs(d+1)
bfs(1)
print(dp[x2-1][y2-1] if dp[x2-1][y2-1]!=inf else -1)

### FIXED CODE ###

import sys
inf=1000002
sys.setrecursionlimit(inf)
from collections import deque
h,w,k=map(int,input().split())
x1,y1,x2,y2=map(int,input().split())
c=[input() for i in range(h)]
dp=[[inf if c[i][j]=="." else -1 for j in range(w)] for i in range(h)]
now=deque()
now.append([x1-1,y1-1])
dp[x1-1][y1-1]=0
#kの更新が遅い
def bfs(d):
    global h,w,k,dp,now,x2,y2
    l=len(now)
    if l==0:
        return
    dp_sub=deque()
    cand=set()
    for i in range(l):
        x,y=now.popleft()
        for j in range(1,min(k+1,w-y)):
            if dp[x][y+j]==inf:
                dp_sub.append([x,y+j,d])
                #dp[x][y+j]=d
                cand.add((x,y+j))
                #now.append([x,y+j])
            else:
                break
        for j in range(1,min(k+1,y+1)):
            if dp[x][y-j]==inf:
                dp_sub.append([x,y-j,d])
                #dp[x][y-j]=d
                cand.add((x,y-j))
                #now.append([x,y-j])
            else:
                break
        for j in range(1,min(k+1,h-x)):
            if dp[x+j][y]==inf:
                dp_sub.append([x+j,y,d])
                #dp[x+j][y]=d
                cand.add((x+j,y))
                #now.append([x+j,y])
            else:
                break
        for j in range(1,min(k+1,x+1)):
            if dp[x-j][y]==inf:
                dp_sub.append([x-j,y,d])
                #dp[x-j][y]=d
                cand.add((x-j,y))
                #now.append([x-j,y])
            else:
                break
    while dp_sub!=deque([]):
        e=dp_sub.popleft()
        dp[e[0]][e[1]]=e[2]
    for i in cand:
        now.append(i)
    bfs(d+1)
bfs(1)
print(dp[x2-1][y2-1] if dp[x2-1][y2-1]!=inf else -1)
### BUGGY CODE ###

from statistics import median
from itertools import combinations

N = int(input())
num_lis = [int(_) for _ in input().split()]

for i in range(N):
    tmp = num_lis.copy()
    tmp.pop(i)
    print(median(tmp))

### FIXED CODE ###


N = int(input())
X = [int(_) for _ in input().split()]
tmp = sorted(X)

one = N // 2 - 1
two = N // 2

for x in X:
    if x <= tmp[one]:
        print(tmp[two])
    else:
        print(tmp[one])
### BUGGY CODE ###

s = str(input())
L = len(s)
dict = [0] * 2019
dict[0] += 1
num = 0
for i in range(L-1, (-1), (-1)):
    num += (int(s[i]) * pow(10,(L-i-1)))%2019
    amari = num % 2019
    dict[amari] += 1
ans = 0
for j in range(2019):
    ans += (dict[j]*(dict[j]-1))/2
print(int(ans))

### FIXED CODE ###

s = str(input())
L = len(s)
dict = [0] * 2019
dict[0] += 1
num = 0
for i in range(L-1, (-1), (-1)):
    num += (int(s[i]) * pow(10,(L-i-1), 2019))%2019
    amari = num % 2019
    dict[amari] += 1
ans = 0
for j in range(2019):
    ans += (dict[j]*(dict[j]-1))/2
print(int(ans))
### BUGGY CODE ###

input_line=int(input())
count=0
input_list=[]
while count < input_line:
  input_list.append(input())
  count+=1
ans={}
max_appeard=0
ans_list=[]
list_set=set(input_list)
for item in list_set:
    appeard=input_list.count(item)
    ans[item]=appeard
    if appeard > max_appeard:
        max_appeard=appeard
for key,value in ans.items():
    if value==max_appeard:
        ans_list.append(key)
ans_list.sort()
for item in ans_list:
  print (item)

### FIXED CODE ###

from collections import defaultdict

H=int(input())
d = defaultdict(int)
for _ in range(H):
    d[input()] += 1
max_appeard=max(d.items(), key=lambda x: x[1])[1]
ans=[k for k,v in d.items() if v == max_appeard]
ans.sort()
for item in ans:
  print (item)
### BUGGY CODE ###

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

B = ""
for i in range(1,n+1):
    B += str(A.index(i)+1)+" "
print(B[:-1])

### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))
B = [0] * n
for i in range(n):
    B[A[i] - 1] = str(i + 1)
print(" ".join(B))
### BUGGY CODE ###

x = int(input())

runrun=[[1,2,3,4,5,6,7,8,9],[]]
count=9
keta=2
end=False
ans=-1

while True:
    if end:
        break

    for ini in runrun[keta-2]:

        if ini%10==0:
            runrun[keta-1].append(ini*10)
            count+=1
            if count==x:
                end=True
                ans=ini*10
                break
            runrun[keta-1].append(ini*10+1)
            count+=1
            if count==x:
                end=True
                ans=ini*10+1
                break

        elif ini%10==9:
            runrun[keta-1].append(ini*10+8)
            count+=1
            if count==x:
                end=True
                ans=ini*10+8
                break
            runrun[keta-1].append(ini*10+9)
            count+=1
            if count==x:
                end=True
                ans=ini*10+9
                break

        else:
            runrun[keta-1].append(ini*10+ini%10-1)
            count+=1
            if count==x:
                end=True
                ans=ini*10+ini%10-1
                break
            runrun[keta-1].append(ini*10+ini%10)
            count+=1
            if count==x:
                end=True
                ans=ini*10+ini%10
                break
            runrun[keta-1].append(ini*10+ini%10+1)
            count+=1
            if count==x:
                end=True
                ans=ini*10+ini%10+1
                break

    keta +=1
    runrun.append([])

print(ans)

### FIXED CODE ###

x = int(input())

runrun=[[1,2,3,4,5,6,7,8,9],[]]
count=9
keta=2
end=False
ans=-1

if x<=9:
    ans=x
    end=True

while True:
    if end:
        break

    for ini in runrun[keta-2]:

        if ini%10==0:
            runrun[keta-1].append(ini*10)
            count+=1
            if count==x:
                end=True
                ans=ini*10
                break
            runrun[keta-1].append(ini*10+1)
            count+=1
            if count==x:
                end=True
                ans=ini*10+1
                break

        elif ini%10==9:
            runrun[keta-1].append(ini*10+8)
            count+=1
            if count==x:
                end=True
                ans=ini*10+8
                break
            runrun[keta-1].append(ini*10+9)
            count+=1
            if count==x:
                end=True
                ans=ini*10+9
                break

        else:
            runrun[keta-1].append(ini*10+ini%10-1)
            count+=1
            if count==x:
                end=True
                ans=ini*10+ini%10-1
                break
            runrun[keta-1].append(ini*10+ini%10)
            count+=1
            if count==x:
                end=True
                ans=ini*10+ini%10
                break
            runrun[keta-1].append(ini*10+ini%10+1)
            count+=1
            if count==x:
                end=True
                ans=ini*10+ini%10+1
                break

    keta +=1
    runrun.append([])

print(ans)
### BUGGY CODE ###

N, P = map(int, input().split())
import math
g = 1
if N ==1:
    print(P)
else:
    for i in range(1,math.ceil(P**(1/N))+1):
        X = i**N
        if X > P:
            break
        else:
            if P % X == 0:
                g = i
    print(g)

### FIXED CODE ###

N, P = map(int, input().split())
import math
g = 1
if N ==1:
    print(P)
else:
    for i in range(1,int((P+1)**(1/N))+1):
        X = i**N
        if X > P:
            break
        else:
            if P % X == 0:
                g = i
    print(g)
### BUGGY CODE ###

n=int(input())
ans=[]
for i in range(n):
    a=int(input())
    if ans.count(a)==0:
        ans.append(a)
    else:
        ans.remove(a)
print(len(ans))

### FIXED CODE ###

import collections
n=int(input())
count=0
a=[int(input()) for _ in range(n)]
a=collections.Counter(a)

for key,value in a.items():
    if value%2==1:
        count+=1
print(count)
### BUGGY CODE ###

from collections import Counter

n = input()
N = int(n)
A = [int(a) for a in input().split()]
q = input()
Q = int(q)
B, C = [], []
for i in range(Q):
    b, c = input().split()
    B.append(int(b))
    C.append(int(c))


my_dict = Counter(A)

def cals_sum(my_dict):
    sum = 0
    for key in my_dict.keys():
        value = my_dict[key]
        sum += int(key) * int(value)
    return sum

for i in range(len(B)):
    b = B[i]
    c = C[i]
    tmpb = my_dict[b] 
    my_dict[b] = 0
    tmpc = my_dict[c]
    my_dict[c] = tmpb + tmpc

    print(cals_sum(my_dict))

### FIXED CODE ###

from collections import Counter

n = input()
N = int(n)
A = [int(a) for a in input().split()]
q = input()
Q = int(q)
B, C = [], []
for i in range(Q):
    b, c = input().split()
    B.append(int(b))
    C.append(int(c))


my_dict = Counter(A)

def cals_sum(my_dict):
    values = [ my_dict[key]*key for key in my_dict.keys() if my_dict[key] != 0]
    #for key in my_dict.keys():
    #    value = my_dict[key]
    #    sum += int(key) * int(value)
    return sum(values)
  
my_sum = cals_sum(my_dict)

for i in range(len(B)):
    b = B[i]
    c = C[i]
    tmpb = my_dict[b] 
    my_dict[b] = 0
    tmpc = my_dict[c]
    my_dict[c] = tmpb + tmpc
    
    my_sum += ((tmpb)*c - tmpb*b)

    print(my_sum)
### BUGGY CODE ###

n = int(input())
p_ls = list(map(int, input().split()))
sum_=1
for i in range(1,n):
  j=0
  #print('%d %d'%(i,j))
  while j<=i:
    if p_ls[j]<p_ls[i]:
      sum_-=1
      break
    j+=1
  sum_+=1
print(sum_)

### FIXED CODE ###

n = int(input())
p_ls = list(map(int, input().split()))
sum_=1
min_=p_ls[0]
for i in range(1,n):
  if min_>=p_ls[i]:
    min_=p_ls[i]
    sum_+=1
print(sum_)
### BUGGY CODE ###

S = input()
N = len(S)
mod = 10 ** 9 + 7

dp = [[0] * 4 for _ in range(N + 10)]
dp[0][0] = 1

for i, s in enumerate(S, start=1):
    if s == "?":
        s = "ABC"
    for j in s:
        dp[i][0] += dp[i-1][0]
        dp[i][1] += dp[i-1][1]
        dp[i][2] += dp[i-1][2]
        dp[i][3] += dp[i-1][3]
        if j == "A":
            dp[i][1] += dp[i-1][0]
            dp[i][1] %= mod
        elif j == "B":
            dp[i][2] += dp[i-1][1]
            dp[i][2] %= mod
        elif j == "C":
            dp[i][3] += dp[i-1][2]
            dp[i][3] %= mod

print(dp[N][3] % mod)

### FIXED CODE ###

S = input()
mod = 10 ** 9 + 7

a, ab, abc, n = 0, 0, 0, 1
for s in S:
    if s == "A":
        a += n
        a %= mod
    elif s == "B":
        ab += a
        ab %= mod
    elif s == "C":
        abc += ab
        abc %= mod
    else:
        a, ab, abc, n = 3 * a + n, 3 * ab + a, 3 * abc + ab, 3 * n
        a %= mod
        ab %= mod
        abc %= mod
        n %= mod

print(abc)
### BUGGY CODE ###

from collections import deque
n,m = map(int,input().split())

a = []
for _ in range(m):
    a.append(list(map(int,input().split())))

b = [[] for i in range(n)]
for i in range(m):
    b[a[i][1]-1].append(a[i][0])
    b[a[i][0]-1].append(a[i][1])
    
c = [-1 for i in range(n)]
c[0] = 0
q = deque([1])
now = 0
count = 0
while q:
    #print(c,q, now)
    count = count + 1
    if count > 10 ** 5:
        print("No")
        exit()
    now = q.popleft() - 1
    for i in range(len(b[now])):
        if c[b[now][i] - 1] == -1 and b[now][i] not in q:
            q.append(b[now][i])
            c[q[-1] - 1] = now + 1
            #print(c)
            
#print(c)
print("Yes")
for i in range(1,len(c)):
    print(c[i])

### FIXED CODE ###

from collections import deque
n,m = map(int,input().split())

b = [[] for i in range(n)]
for i in range(m):
    a=list(map(int,input().split()))
    b[a[1]-1].append(a[0])
    b[a[0]-1].append(a[1])
    
c = [-1 for i in range(n)]
c[0] = 0
q = deque([1])
now = 0
count = 0
while q:
    #print(c,q, now)
    count = count + 1
    if count > n:
        print("No")
        exit()
    now = q.popleft() - 1
    for i in range(len(b[now])):
        #count = count + 1
        #print(now+1, "=>", b[now][i])
        if c[b[now][i] - 1] == -1:
            q.append(b[now][i])
            c[q[-1] - 1] = now + 1
            #print(c)
            
#print(count)
print("Yes")
for i in range(1,len(c)):
    print(c[i])
### BUGGY CODE ###

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

for i in range(n):
    print(h.index(i+1)+1, end=" ")

### FIXED CODE ###

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

n_list = list(range(1,n+1))

h_dict = dict(zip(h,n_list))


for i in range(1,n+1):
    print(h_dict[i], end=" ")