from collections import deque N = int(input()) L = [] for i in range(N): L.append([]) for i in range(N-1): a,b = map(int, input().split()) L[a-1].append(b-1) L[b-1].append(a-1) CHECK = [] for i in range(N): if len(L[i])==1: CHECK.append(i) root = CHECK[0] q = deque() c = deque() STEP = [-1]*N STEP[root]=0 q.append(root) c.append(0) while len(q) !=0: i = q.popleft() cnt = c.popleft() for l in L[i]: if STEP[l]==-1: STEP[l]=cnt+1 q.append(l) c.append(cnt+1) ans = True for i in range(len(CHECK)): ans = ans and (STEP[CHECK[i]]==0 or STEP[CHECK[i]]==STEP[CHECK[1]]) root = CHECK[-1] STEP = [-1]*N STEP[root]=0 q.append(root) c.append(0) while len(q) !=0: i = q.popleft() cnt = c.popleft() for l in L[i]: if STEP[l]==-1: STEP[l]=cnt+1 q.append(l) c.append(cnt+1) for i in range(len(CHECK)): ans = ans and (STEP[CHECK[i]]==0 or STEP[CHECK[i]]==STEP[CHECK[0]]) if ans: print('Yes') else: print('No')