n, k = map(int,input().split()) r = [0] * n x = [0] * n ikeru = [[] for i in range(n + 1)] for i in range(n): r[i], x[i] = map(int,input().split()) ikeru[i].append(r[i]) ikeru[r[i]].append(i) for st in range(n): tmp_x = x[::] tmp_v = [0] * n tmp_rx = [0] * (n + 1) tmp_rv = [0] * (n + 1) tmp_x[st] = 0 tmp_v[st] = 1 mada = [n] tansaku = [0] * (n + 1) tansaku[n] = 1 while mada: i = mada.pop() for j in ikeru[i]: if tansaku[j]: continue tansaku[j] = 1 tmp_rx[j] += tmp_rx[i] + tmp_x[j] tmp_rv[j] += tmp_rv[i] + tmp_v[j] mada.append(j) mode = 1 m_lb = - 10 ** 18 m_ub = 10 ** 18 for i in range(n): tar_x = tmp_rx[i] - tmp_rx[i+1] tar_v = tmp_rv[i] - tmp_rv[i+1] # 0 <= tar_x + tar_v * M <= K if tar_v == 0: if not 0 <= tar_x <= k: mode = 0 elif tar_v == 1: m_lb = max(m_lb, - tar_x) m_ub = min(m_ub, k - tar_x) else: assert tar_v == -1 m_lb = max(m_lb, tar_x - k) m_ub = min(m_ub, tar_x) if not m_lb <= m_ub: mode = 0 if mode: print("Yes") else: print("No")