class INPUT: def __init__(self): self._l=open(0).read().split() self._length=len(self._l) self._index=0 return def stream(self,k=1,f=int,f2=False): assert(-1 return left all listを変数で受け取るとき、必ずlistをTrueにすること。 """ class dsu: def __init__(self,n): assert n>0,"n must be Natural" self.n=n self.parents=[-1]*n return def find(self,x): assert xself.parents[y]: x,y=y,x self.parents[x]+=self.parents[y] self.parents[y]=x return def size(self,x): assert x1: print("No") return if is_cycle: next_point=-1 que=deque() que.append([linked[0],-1]) while que: q=que.pop() for j in to[q[0]]: if j[1]==q[1]: continue if seen[j[0]]: root=j[0] next_point=q[0] ans[j[1]]=root+1 que.clear() break que.append([j[0],j[1]]) seen[0]=1 if next_point==-1: print("No") return dq=deque() dq.append(root) while dq: q=dq.pop() for j in to[q]: if ans[j[1]]==-1: ans[j[1]]=j[0]+1 dq.append(j[0]) for i in ans: if i==-1: print("No") return print("Yes") for i in ans: print(i) return main()