#define _GLIBCXX_DEBUG #include using namespace std; const int LOG = 13; const long long INF = 1000000000000000000; int main(){ int N, K; cin >> N >> K; vector R(N); vector X(N); for (int i = 0; i < N; i++){ cin >> R[i] >> X[i]; } vector d(N + 1, 0); vector s(N + 1, 0); for (int i = N - 1; i >= 0; i--){ d[i] = d[R[i]] + 1; s[i] = s[R[i]] + X[i]; } vector> pp(LOG, vector(N + 1, -1)); for (int i = 0; i < N; i++){ pp[0][i] = R[i]; } for (int i = 0; i < LOG - 1; i++){ for (int j = 0; j <= N; j++){ if (pp[i][j] != -1){ pp[i + 1][j] = pp[i][pp[i][j]]; } } } auto climb = [&](int v, int k){ for (int i = 0; i < LOG; i++){ if ((k >> i & 1) == 1){ v = pp[i][v]; } } return v; }; auto lca = [&](int u, int v){ if (d[u] > d[v]){ swap(u, v); } v = climb(v, d[v] - d[u]); if (u == v){ return u; } for (int i = LOG - 1; i >= 0; i--){ if (pp[i][u] != pp[i][v]){ u = pp[i][u]; v = pp[i][v]; } } return R[u]; }; vector add(N + 1, 0); int add_all = 0; vector> mn(LOG, vector(N + 1, -INF)); vector> mx(LOG, vector(N + 1, INF)); auto path_chmax = [&](int u, int v, long long x){ if (u == v){ return; } int D = 31 - __builtin_clz(d[u] - d[v]); mn[D][u] = max(mn[D][u], x); int p = climb(u, (d[u] - d[v]) - (1 << D)); mn[D][p] = max(mn[D][p], x); }; auto path_chmin = [&](int u, int v, long long x){ if (u == v){ return; } int D = 31 - __builtin_clz(d[u] - d[v]); mx[D][u] = min(mx[D][u], x); int p = climb(u, (d[u] - d[v]) - (1 << D)); mx[D][p] = min(mx[D][p], x); }; for (int i = 0; i < N; i++){ int w = lca(i, i + 1); if (s[i] - s[i + 1] < 0 || s[i] - s[i + 1] > K){ add_all++; add[i]--; add[i + 1]--; add[w] += 2; } path_chmax(i, w, -s[i] + s[i + 1]); path_chmin(i, w, -s[i] + s[i + 1] + K); path_chmax(i + 1, w, s[i] - s[i + 1] - K); path_chmin(i + 1, w, s[i] - s[i + 1]); } for (int i = LOG - 2; i >= 0; i--){ for (int j = 0; j <= N; j++){ mx[i][j] = min(mx[i][j], mx[i + 1][j]); mn[i][j] = max(mn[i][j], mn[i + 1][j]); if (pp[i][j] != -1){ mx[i][j] = min(mx[i][j], mx[i + 1][pp[i][j]]); mn[i][j] = max(mn[i][j], mn[i + 1][pp[i][j]]); } } } vector ok(N, true); for (int i = 0; i < N; i++){ add[R[i]] += add[i]; if (add[i] + add_all > 0){ ok[i] = false; } } for (int i = 0; i < N; i++){ if (mn[0][i] > mx[0][i]){ ok[i] = false; } } for (int i = 0; i < N; i++){ if (ok[i]){ cout << "Yes" << endl; } else { cout << "No" << endl; } } }