local n = io.read("*n") local edge = {} for i = 1, n do edge[i] = {} end for i = 1, n - 1 do local a, b = io.read("*n", "*n") table.insert(edge[a], b) table.insert(edge[b], a) end local c = 0 for i = 1, n do if 3 <= #edge[i] then if c == 0 then c = i else print("No") os.exit() end end end if c == 0 then print("Yes") os.exit() end local len = {} for i = 1, n do len[i] = -1 end len[c] = 0 local tasks = {c} for i = 1, n do local src = tasks[i] for j = 1, #edge[src] do local dst = edge[src][j] if len[dst] < 0 then len[dst] = len[src] + 1 table.insert(tasks, dst) end end end local z = 0 for i = 1, n do if 1 == #edge[i] then if z == 0 then z = len[i] elseif z ~= len[i] then print("No") os.exit() end end end print("Yes")