from heapq import heapify, heappop, heappush from collections import defaultdict from collections import deque class UnionFind(object): def __init__(self, n=1): self.par = [i for i in range(n)] self.rank = [0 for _ in range(n)] self.size = [1 for _ in range(n)] def find(self, x): """ x が属するグループを探索して親を出す。 """ if self.par[x] == x: return x else: self.par[x] = self.find(self.par[x]) return self.par[x] def union(self, x, y): """ x と y のグループを結合 """ x = self.find(x) y = self.find(y) if x != y: if self.rank[x] < self.rank[y]: x, y = y, x if self.rank[x] == self.rank[y]: self.rank[x] += 1 self.par[y] = x self.size[x] += self.size[y] def is_same(self, x, y): """ x と y が同じグループか否か """ return self.find(x) == self.find(y) def get_size(self, x): """ x が属するグループの要素数 """ x = self.find(x) return self.size[x] def main(): N = int(input()) deg = [0]*N dic = defaultdict(list) uf = UnionFind(N) for i in range(N): a,b = map(int,input().split()) a -= 1; b -= 1 deg[a] += 1 deg[b] += 1 dic[a].append((b,i)) #行先、辺の番号 dic[b].append((a,i)) uf.union(a,b) G = [[] for _ in range(N)] PL = set([]) for i in range(N): par = uf.find(i) PL.add(par) heappush(G[par], (deg[i],i)) #print(G) Q = deque([]) #for i in range(N): # heappush(PQ,(deg[i],i)) ret = [] used_point = set([]) used_edge = set([]) for par in PL: Q = [] d,i = heappop(G[par]) if i in used_point: continue heappush(Q,(d,i)) while G[par] and G[par][0][0] == 1: #出る数が1なら追加 d,i = heappop(G[par]) if i in used_point: continue heappush(Q,(d,i)) while Q: d,v = heappop(Q) #print("v",v) if v in used_point: continue for u,edge_idx in dic[v]: #print(u,edge_idx,used_edge) if edge_idx in used_edge: continue ret.append(v) used_point.add(v) used_edge.add(edge_idx) deg[v] -= 1 deg[u] -= 1 if u not in used_point: heappush(Q,(deg[u],u)) break #print(ret) if len(ret) == N: print('Yes') ret = [x+1 for x in ret] print(*ret,sep="\n") else: print('No') if __name__ == '__main__': main()