Problem:


Score: 400 points

Problem Statement

There is a cave.

The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside.

It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage.

Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1.

If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible.

Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.

Constraints

All values in input are integers.

2 \leq N \leq 10^5

1 \leq M \leq 2 \times 10^5

1 \leq A_i, B_i \leq N\ (1 \leq i \leq M)

A_i \neq B_i\ (1 \leq i \leq M)

One can travel between any two rooms by traversing passages.

Input

Input is given from Standard Input in the following format:

N M
A_1 B_1
:
A_M B_M

Output

If there is no way to place signposts satisfying the objective, print No.

Otherwise, print N lines. The first line should contain Yes, and the i-th line (2 \leq i \leq N) should contain the integer representing the room indicated by the signpost in Room i.

Sample Input 1

4 4
1 2
2 3
3 4
4 2

Sample Output 1

Yes
1
2
2

If we place the signposts as described in the sample output, the following happens:

Starting in Room 2, you will reach Room 1 after traversing one passage: (2) \to 1. This is the minimum number of passages possible.

Starting in Room 3, you will reach Room 1 after traversing two passages: (3) \to 2 \to 1. This is the minimum number of passages possible.

Starting in Room 4, you will reach Room 1 after traversing two passages: (4) \to 2 \to 1. This is the minimum number of passages possible.

Thus, the objective is satisfied.

Sample Input 2

6 9
3 4
6 1
2 4
5 3
4 6
1 5
6 2
4 5
5 6

Sample Output 2

Yes
6
5
5
1
1

If there are multiple solutions, any of them will be accepted.



Sample input:
4 4
1 2
2 3
3 4
4 2


Sample output:
Yes
1
2
2

Submission status: Wrong Answer

Solution code:
import sys


# import math
import heapq

# input = sys.stdin.readline
from collections import deque

def main():
    n, m = map(int,input().split())
    room =[[]for _ in range(n+1)]
    for i in range(m):
        a,b = map(int,input().split())
        room[a].append(b)
        room[b].append(a)

    point = [0] *(n+1) #未踏0 その他　親
    d = deque([1])

    while len(d) > 0:
        p = d.popleft()
        for v in room[p]:
            if point[v] ==0:
                d.append(v)
                point[v] =p

    if 0 in point[1:]:
        print('No')
    else:
        print("Yes")
        print("n".join(map(str,point[2:])))












if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys


# import math
import heapq

# input = sys.stdin.readline
from collections import deque

def main():
    n, m = map(int,input().split())
    room =[[]for _ in range(n+1)]
    for i in range(m):
        a,b = map(int,input().split())
        room[a].append(b)
        room[b].append(a)

    point = [0] *(n+1) #未踏0 その他　親
    d = deque([1])

    while len(d) > 0:
        p = d.popleft()
        for v in room[p]:
            if point[v] ==0:
                d.append(v)
                point[v] =p

    if 0 in point[1:]:
        print('No')
    else:
        print("Yews")
        print("n".join(map(str,point[2:])))












if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
l=[[] for _ in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  l[a-1].append(b-1)
  l[b-1].append(a-1)
queue=[0]
visit=[0]*n
visit[0]=1
ans=[0]*n

while len(queue)>0: 
  now=queue.pop(0)
  for p in l[now]:
    if visit[p]==0:
      visit[p]+=1
      queue.append(p)
      ans[p]=now+1
k=ans[1:]
print(*k)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
l=[[] for _ in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  l[a-1].append(b-1)
  l[b-1].append(a-1)
queue=[0]
visit=[0]*n
visit[0]=1
ans=[0]*n
 
now=queue.pop(0)
for p in l[now]:
  if visit[p]==0:
    visit[p]+=1
    queue.append(p)
    ans[p]=now+1
print(ans[1:])

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
l=[[] for _ in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  l[a-1].append(b-1)
  l[b-1].append(a-1)
queue=[0]
visit=[0]*n
visit[0]=1
ans=[0]*n

now=queue.pop(0)
for p in l[now]:
  if visit[p]==0:
    visit[p]+=1
    queue.append(p)
    ans[p]=now
print(ans[1:])

Submission status: Wrong Answer

Solution code:
def main():
	# import sys
	# input = sys.stdin.readline
	# k = int(input())
	# s = str(input())
	# a,b = map(float,input().split())
	#1行R列
	# h = list(map(int,input().split()))
	# h = tuple(map(int,input().split()))
	#R行1列
	# l = [int(input()) for i in range(n)]
	#R行C列
	# l = [list(map(int, input().split())) for i in range(m)]
	
	from collections import deque
	n,m = map(int,input().split())
	l = [list(map(int, input().split())) for i in range(m)]
	graph = [[] for _ in range(n+1)]
	
	for i in range(m):
		a,b = l[i]
		graph[a].append(b)
		graph[b].append(a) #双方向に描くんだっけ？

	# print("graph is ",graph)

	dist = [-1] * (n+1)
	dist[0] = 0
	dist[1] = 0
	# print("dist is ",dist)

	d = deque()
	d.append(1) #なんでappend 1するんだっけ

	while d:
		v = d.popleft()
		for i in graph[v]:
			# print("i is ",i)
			if dist[i] != -1:
				continue
			dist[i] = dist[v] + 1
			d.append(i)

	# print("dist is ",dist)
	if graph[1] == '':
		print("No")
	else:
		print("Yes")
		for i in range(2,n+1):
			print(dist[i])
	


if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
from collections import deque

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

graph = [[] for _ in range(n+1)]

for i in range(m):
 a, b = map(int, input().split())
 graph[a].append(b)
 graph[b].append(a)

#a,b = 1 2 (頂点1,2が隣接)
#a,b = 2 3 (頂点2,3が隣接)
#a,b = 3 4 (頂点3,4が隣接)
#a,b = 4 2 (頂点2,2が隣接)

#G = [[],[2],[1,3,4],[2,4],[3,2]]

ans = [0] * (n-1)

d = deque()
d.append(1)
#頂点1を訪問した

while d:
 v = d.popleft()
 for i in graph[v]:
   if ans[i-2] != 0:
     continue
   ans[i-2] = v
   d.append(i)

print("Yes")
print(*ans, sep="\n")

Submission status: Wrong Answer

Solution code:
from collections import deque

N,M = map(int,input().split())
grap = [[] for _ in range(N+1)]
for i in range(M):
    a,b = map(int,input().split())
    grap[a].append(b)
    grap[b].append(a)

dist = [-1] * (N +1)
dist[0] = 0
dist[1] = 0

d = deque()
d.append(1)

while d:
    v = d.popleft()
    for i in grap[v]:
        if dist[i] != -1:
            continue
        dist[i] = dist[v] + 1
        d.append(i)

if -1 in dist:
    print('No')
else:
    print('Yes',*dist[2:],sep='\n')

Submission status: Wrong Answer

Solution code:
import time
start = time.time()
# ----------------------------------------
n, m = map(int, input().split())
e = [[] for _ in range(n+1)]

for i in range(0, m):
	a, b = map(int, input().split())
	e[a].append(b)
	e[b].append(a)
depth = {1:0}
while len(depth) < n:
	for i in range(2, n+1):
		if i in depth: continue
		for v in e[i]:
			if v in list(depth.keys()) and i not in depth:
				depth[i] = depth[v] + 1
	if time.time() - start > 1.8: break

if len(depth) == n:
	print("yes")
	sorted_depth = sorted(depth.items(), key=lambda x: x[0])
	for i in range(1, n):
		print(sorted_depth[i][1])
else:
	print("no")

Submission status: Wrong Answer

Solution code:
import sys
N, M = map(int, input().split())
Nlist = [0]*(N+1)
for i in range(1,M+1):
    A, B = map(int, input().split())
    if Nlist[A]>B or Nlist[A]==0:
        Nlist[A]=B
    if Nlist[B]>A or Nlist[B]==0:
        Nlist[B]=A

print('Yes')
for i in range(N-1):
    print(Nlist[i+2])

Submission status: Wrong Answer

Solution code:
import sys
N, M = map(int, input().split())
Nlist = [0]*(N+1)
for i in range(M):
    A, B = map(int, input().split())
    if Nlist[A]>B or Nlist[A]==0:
        Nlist[A]=B
    if Nlist[B]>A or Nlist[B]==0:
        Nlist[B]=A

print('Yes')
for i in range(N-1):
    print(Nlist[i+1])

Submission status: Wrong Answer

Solution code:
from collections import deque
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
roots = [[] for _ in range(n)]
signs = [-1 for _ in range(n)]

for _ in range(m):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    roots[a].append(b)
    roots[b].append(a)

queue = deque([0])
signs[0] = 0

while queue:
    room = queue.popleft()
    for root in roots[room]:
        if signs[root] == -1:
            signs[root] = room
            queue.append(room)

print('Yes')
for i in signs[1:]:
    print(i + 1)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
ans=[0]*n
num1=[[] for _ in range(n)]
def ap(num01,num02):
    num1[num01-1].append(num02)
    num1[num02-1].append(num01)
for i in range(m):
    a,b=map(int,input().split())
    ap(a,b)
queue=[1]
def apq(num01):
    queue.append(num01)
def qp():
    return queue.pop(0)
for i in range(n):
    if len(queue)==0:
        break
    num=qp()
    print(num)
    for j in range(len(num1[num-1])):
        if ans[num1[num-1][j]-1]==0:
            apq(num1[num-1][j])
            ans[num1[num-1][j]-1]=num
if ans.count(0)!=0:
    print("No")
else:
    print("Yes")
    for i in range(1,n):
        print(ans[i])

Submission status: Wrong Answer

Solution code:
from collections import deque
n, m = [int(i) for i in input().split()]
rooms = [[] for i in range(n)]
dist = [-1] * n
for i in range(m):
    a, b = [int(i) for i in input().split()]
    rooms[a-1].append(b)
    rooms[b-1].append(a)

que = deque()
que.append(1)
dist[0] = 0
ans = [0] * n
while(len(que) != 0):
    v = que.pop()
    for i in rooms[v-1]:
        if dist[i-1] == -1:
            dist[i-1] = dist[v-1] + 1
            que.append(i)
            ans[i-1] = v
print("Yes")
for i in ans[1:]:
    print(i)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
root = [[] for _ in range(n)]
for i in range(m):
    aa,bb =map(int,input().split())
    aa-=1
    bb-=1
    root[aa].append(bb)
    root[bb].append(aa)

from collections import deque

q = deque([(-1,0)])
been=[0]*n
ans=[0]*n
while q:
    parent,now = q.popleft()
    been[now]=1
    ans[now]=parent
    for to in root[now]:
        if been[to]==0:
            q.append((now,to))

print("Yes")
for i in range(1,n):
    print(ans[i]+1)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
root = [[] for _ in range(n)]
for i in range(m):
    aa,bb =map(int,input().split())
    aa-=1
    bb-=1
    root[aa].append(bb)
    root[bb].append(aa)

from collections import deque

q = deque([(-1,0)])
been=[0]*n
ans=[0]*n
while q:
    parent,now = q.pop()
    been[now]=1
    ans[now]=parent
    for to in root[now]:
        if been[to]==0:
            q.append((now,to))

print("Yes")
for i in range(1,n):
    print(ans[i]+1)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
AB = [""] * M

for c in range(M):
    AB[c] = list(map(int, input().split()))
    AB[c].sort()

AB.sort()

Submission status: Wrong Answer

Solution code:
import sys,bisect,string,math,time,functools,random,fractions
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
rep=range
def Golf():n,*t=map(int,open(0).read().split())
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def MI():return map(int,input().split())
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def RA():return map(int,open(0).read().split())
def GI(V,E,ls=None,Directed=False,index=1):
    org_inp=[];g=[[] for i in range(V)]
    FromStdin=True if ls==None else False
    for i in range(E):
        if FromStdin:
            inp=LI()
            org_inp.append(inp)
        else:
            inp=ls[i]
        if len(inp)==2:
            a,b=inp;c=1
        else:
            a,b,c=inp
        if index==1:a-=1;b-=1
        aa=(a,c);bb=(b,c);g[a].append(bb)
        if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0},boundary=1):
    #h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0},boundary=1) # sample usage
    mp=[boundary]*(w+2);found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[boundary]+[mp_def[j] for j in s]+[boundary]
    mp+=[boundary]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def accum(ls):
    rt=[0]
    for i in ls:rt+=[rt[-1]+i]
    return rt
def bit_combination(n,base=2):
    rt=[]
    for tb in range(base**n):s=[tb//(base**bt)%base for bt in range(n)];rt+=[s]
    return rt
def gcd(x,y):
    if y==0:return x
    if x%y==0:return y
    while x%y!=0:x,y=y,x%y
    return y
def YN(x):print(['NO','YES'][x])
def Yn(x):print(['No','Yes'][x])
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)

mo=10**9+7
inf=float('inf')
FourNb=[(-1,0),(1,0),(0,1),(0,-1)];EightNb=[(-1,0),(1,0),(0,1),(0,-1),(1,1),(-1,-1),(1,-1),(-1,1)];compas=dict(zip('WENS',FourNb));cursol=dict(zip('LRUD',FourNb))
l_alp=string.ascii_lowercase
#sys.setrecursionlimit(10**7)
read=sys.stdin.buffer.read
readline=sys.stdin.buffer.readline
input=lambda: sys.stdin.readline().rstrip()

class Tree:
    def __init__(self,inp_size=None,ls=None,init=True,index=1):
        self.LCA_init_stat=False
        self.ETtable=[]
        if init:
            if ls==None:
                self.stdin(inp_size,index=index)
            else:
                self.node_size=len(ls)+1
                self.edges,_=GI(self.node_size,self.node_size-1,ls,index=index)
        return
 
    def stdin(self,inp_size=None,index=1):
        if inp_size==None:
            self.node_size=int(input())
        else:
            self.node_size=inp_size
        self.edges,_=GI(self.node_size,self.node_size-1,index=index)
        return
    
    def listin(self,ls,index=0):
        self.node_size=len(ls)+1
        self.edges,_=GI(self.node_size,self.node_size-1,ls,index=index)
        return
 
    def dfs(self,x,func=lambda pr,prv,nx,dist:prv+dist,root_v=0):
        q=deque([x])
        v=[None]*self.node_size
        v[x]=root_v
        while q:
            c=q.pop()
            for nb,d in self.edges[c]:
                if v[nb]==None:
                    q.append(nb)
                    v[nb]=func(c,v[c],nb,d)
        return v
 
    def bfs(self,x,func=lambda pr,prv,nx,dist:prv+dist,root_v=0):
        q=deque([x])
        v=[None]*self.node_size
        v[x]=root_v
        while q:
            c=q.popleft()
            for nb,d in self.edges[c]:
                if v[nb]==None:
                    q.append(nb)
                    v[nb]=func(c,v[c],nb,d)
        return v
 
    def parent(self,x):
        return self.dfs(0,func=lambda pr,prv,nx,dist:pr,root_v=-1)
 
    def topological_sort(self,x):  # return topological sort of the tree
        tps=[]
        q=deque([x])
        v=[None]*self.node_size
        v[x]=0
        while q:
            c=q.popleft()
            tps.append(c)
            for nb,d in self.edges[c]:
                if v[nb]==None:
                    q.append(nb)
                    v[nb]=0
        return tps
 
    def EulerTour(self,x):
        q=deque()
        q.append(x)
        self.depth=[None]*self.node_size
        self.depth[x]=0
        self.ETtable=[]
        self.ETdepth=[]
        self.ETin=[-1]*self.node_size
        self.ETout=[-1]*self.node_size
        cnt=0
        while q:
            c=q.pop()
            if c<0:
                ce=~c
            else:
                ce=c
                for nb,d in self.edges[ce]:
                    if self.depth[nb]==None:
                        q.append(~ce)
                        q.append(nb)
                        self.depth[nb]=self.depth[ce]+1
            self.ETtable.append(ce)
            self.ETdepth.append(self.depth[ce])
            if self.ETin[ce]==-1:
                self.ETin[ce]=cnt
            else:
                self.ETout[ce]=cnt
            cnt+=1
        return
    
    def LCA_init(self,root):
        self.EulerTour(root)
        self.st=SparseTable(self.ETdepth,init_func=min,init_idl=inf)
        #self.st=SegTree(self.node_size*2-1,self.ETdepth,function=min,ide=inf)
        self.LCA_init_stat=True
        return
    
    def LCA(self,root,x,y):
        if self.LCA_init_stat==False:
            self.LCA_init(root)
        xin,xout=self.ETin[x],self.ETout[x]
        yin,yout=self.ETin[y],self.ETout[y]
        a=min(xin,yin)
        b=max(xout,yout,xin,yin)
        id_of_min_dep_in_et=self.st.query_id(a,b+1)
        return self.ETtable[id_of_min_dep_in_et]
 
    def __str__(self):
        return  str(self.edges)
 
    def show(self):
        if all([all([d==1 for nd,d in edge]) for edge in self.edges]):
            print( [[nd for nd,d in edge] for edge in self.edges] )
        else:
            print(self)
 
class SparseTable: # O(N log N) for init, O(1) for query(l,r)
    def __init__(self,ls,init_func=min,init_idl=float('inf')):
        self.func=init_func
        self.idl=init_idl
        self.size=len(ls)
        self.N0=self.size.bit_length()
        self.table=[ls[:]]
        self.index=[list(range(self.size))]
        self.lg=[0]*(self.size+1)
        
        for i in range(2,self.size+1):
            self.lg[i]=self.lg[i>>1]+1
 
        for i in range(self.N0):
            tmp=[self.func(self.table[i][j],self.table[i][min(j+(1<<i),self.size-1)]) for j in range(self.size)]
            tmp_id=[self.index[i][j] if self.table[i][j]==self.func(self.table[i][j],self.table[i][min(j+(1<<i),self.size-1)]) else self.index[i][min(j+(1<<i),self.size-1)] for j in range(self.size)]
            self.table+=[tmp]
            self.index+=[tmp_id]
    
    # return func of [l,r)
    def query(self,l,r):
        if r>self.size:r=self.size
        #N=(r-l).bit_length()-1
        N=self.lg[r-l]
        return self.func(self.table[N][l],self.table[N][max(0,r-(1<<N))])
    
    # return index of which val[i] = func of v among [l,r)
    def query_id(self,l,r):
        if r>self.size:r=self.size
        #N=(r-l).bit_length()-1
        N=self.lg[r-l]
        a,b=self.index[N][l],self.index[N][max(0,r-(1<<N))]
        if self.table[0][a]==self.func(self.table[N][l],self.table[N][max(0,r-(1<<N))]):
            b=a
        return b
    
    # return boundary index of r such that func({table[i]} =< x , i in [pos,r]
    def right_bound(self,pos,x):
        k=(self.size-pos).bit_length()
        for j in range(k)[::-1]:
            nx=pos+(1<<j)
            if nx<n and self.query(pos,nx+1)<=x:
                pos+=(1<<j)
        return pos
    
    # return boundary index of l such that func({table[i]} =< x , i in [l,pos]
    def left_bound(self,pos,x):
        k=pos.bit_length()
        for j in range(k)[::-1]:
            nx=pos-(1<<j)
            if 0<=nx and self.query(nx,pos+1)<=x:
                pos-=(1<<j)
        return pos
 
    def __str__(self):
        return str(self.table[0])
 
    def print(self):
        for i in self.table:
            print(*i)


show_flg=False
show_flg=True
ans=0


class Graph:
    def __init__(self,inp_node_size=None,inp_edge_size=None,ls=None,init=True,Directed=False,index=1):
        if init:
            if ls==None:
                self.stdin(inp_node_size,inp_edge_size,Directed=Directed,index=index)
            else:
                self.listin(ls,Directed=Directed,index=index)
        else:
            self.edges=[]
        return
 
    def stdin(self,inp_node_size=None,inp_edge_size=None,Directed=False,index=1):
        if (inp_node_size,inp_edge_size)==(None,None):
            self.node_size,self.edge_size=LI()
            self.edges,_=GI(self.node_size,self.edge_size,Directed=Directed,index=index)
        else:
            self.node_size=inp_node_size
            self.edge_size=inp_edge_size
            self.edges,_=GI(self.node_size,self.edge_size,Directed=Directed,index=index)
        return
    
    def listin(self,inp_node_size,ls,Directed=False,index=0):
        self.node_size=inp_node_size
        self.edge_size=len(ls)
        self.edges,_=GI(self.node_size,self.edge_size,ls,Directed=Directed,index=index)
        return
 
    def dfs(self,x,func=lambda pr,prv,nx,dist:prv+dist,root_v=0):
        q=deque([x])
        v=[None]*self.node_size
        v[x]=root_v
        while q:
            c=q.pop()
            for nb,d in self.edges[c]:
                if v[nb]==None:
                    q.append(nb)
                    v[nb]=func(c,v[c],nb,d)
        return v
 
    def bfs(self,x,func=lambda pr,prv,nx,dist:prv+dist,root_v=0):
        q=deque([x])
        v=[None]*self.node_size
        v[x]=root_v
        while q:
            c=q.popleft()
            for nb,d in self.edges[c]:
                if v[nb]==None:
                    q.append(nb)
                    v[nb]=func(c,v[c],nb,d)
        return v

    def parent(self,x):
        return self.dfs(0,func=lambda pr,prv,nx,dist:pr,root_v=-1)
 
    def topological_sort(self,x):  # return topological sort of the tree
        tps=[]
        q=deque([x])
        v=[None]*self.node_size
        v[x]=0
        while q:
            c=q.popleft()
            tps.append(c)
            for nb,d in self.edges[c]:
                if v[nb]==None:
                    q.append(nb)
                    v[nb]=0
        return tps

    def __str__(self):
        return  str(self.edges)
 
    def show(self):
        if all([all([d==1 for nd,d in edge]) for edge in self.edges]):
            print( [[nd for nd,d in edge] for edge in self.edges] )
        else:
            print(self)

gr=Graph(init=False)
'''
n,m=LI()
ls=[]
for i in rep(m):
    ls+=[LI_()]

#gr.listin(n,ls,index=0,Directed=True)
v=gr.dfs(0)
'''

gr=Graph()
show('Yes')
for i in gr.parent(0)[1:]:
    show(i+1)