import heapq from collections import defaultdict def dijkstra(s): global N, P, Leaf D = [float('inf')] * N D[s] = 0 q = [(0, s)] heapq.heapify(q) while len(q) > 0: cost, c = heapq.heappop(q) if cost > D[c]: continue for p in Edge[c]: if D[p] > D[c] + 1: D[p] = D[c] + 1 heapq.heappush(q, (D[p], p)) res = -1 for e in Leaf: if res < 0: res = D[e] elif res != D[e]: return -1 return res N = int(input()) Edge = defaultdict(list) for _ in range(N-1): v, u = map(int, input().split()) Edge[v-1].append(u-1) Edge[u-1].append(v-1) Leaf = [] Start = -1 NG = False for k, v in Edge.items(): if len(v) == 1: Leaf.append(k) elif len(v) >= 3: if Start < 0: Start = k else: NG = True break if NG: print('No') elif Start < 0: print('Yes') else: print('Yes' if dijkstra(Start) >= 0 else 'No')