N = int(input()) G = [[] for _ in range(N)] Gnum = [0] * N for _ in range(N-1): a,b = map(int,input().split()) a -= 1 b -= 1 G[a].append(b) G[b].append(a) Gnum[a] += 1 Gnum[b] += 1 ha = 0 has = set() for j in range(N): i = Gnum[j] if i == 1: ha += 1 has.add(j) import sys if ha == 2: print('Yes') exit() count = 0 center = -1 for j in range(N): i = Gnum[j] if 2 < i < ha: print('No') exit() if i == ha: count += 1 center = j if count != 1: print('No') exit() dist = [0] * N stack = [(center,-1)] while stack: now,parent = stack.pop() for v in G[now]: if v == parent:continue dist[v] = dist[now] + 1 stack.append((v,now)) s = set() for v in has: s.add(dist[v]) if len(s) == 1: print('Yes') else: print('No') """ print(s) print(dist) print(center) """