#include using namespace std; 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]; } for (int i = 0; i < N; i++){ vector>> E(N + 1); for (int j = 0; j < N; j++){ if (j != i){ E[j].push_back(make_pair(X[j], R[j])); E[R[j]].push_back(make_pair(-X[j], j)); } } int cnt = 0; vector c(N + 1, -1); vector d(N + 1, 0); for (int j = 0; j <= N; j++){ if (c[j] == -1){ c[j] = cnt; queue Q; Q.push(j); while (!Q.empty()){ int v = Q.front(); Q.pop(); for (pair P : E[v]){ int w = P.second; if (c[w] == -1){ c[w] = cnt; d[w] = d[v] + P.first; Q.push(w); } } } cnt++; } } bool ok = true; long long mn = -INF, mx = INF; for (int j = 0; j < N; j++){ if (c[j] == c[j + 1]){ if (d[j + 1] - d[j] < 0 || d[j + 1] - d[j] > K){ ok = false; } } if (c[j] == 0 && c[j + 1] == 1){ mx = min(mx, K - d[j + 1] + d[j]); mn = max(mn, -d[j + 1] + d[j]); } if (c[j] == 1 && c[j + 1] == 0){ mx = min(mx, d[j + 1] - d[j]); mn = max(mn, -K + d[j + 1] - d[j]); } } if (mn > mx){ ok = false; } if (ok){ cout << "Yes" << endl; } else { cout << "No" << endl; } } }