#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N,K; cin >> N >> K; vectorR(N); vectorX(N); for(int i = 0; i < N; i++) { cin >> R[i] >> X[i]; } for(int i = 0; i < N; i++) { vectortmp1(N),tmp2(N+1); vectorf(N),f2(N+1); for(int j = N-1; j >= 0; j--) { if(i == j) { f[j] = 1; tmp2[j] = tmp2[j+1]; f2[j] = f2[j+1]+1; } else { long long sum1 = tmp2[j+1]-tmp2[R[j]]; int sum2 = f2[j+1]-f2[R[j]]; tmp1[j] = X[j]-sum1; if(sum2 == 1) { f[j] = 2; } if(sum2 == 2) { f[j] = 1; } tmp2[j] = tmp2[j+1]+tmp1[j]; f2[j] = f2[j+1]+f[j]; } } bool ok = true; long long mi = 0,mx = K; for(int j = 0; j < N; j++) { if(f[j] == 0) { if(0 <= tmp1[j] && tmp1[j] <= K) { //ok } else { ok = false; } } if(f[j] == 1) { if(tmp1[j] < 0) { mi = max(mi,-tmp1[j]); } mx = min(mx,K-tmp1[j]); } if(f[j] == 2) { if(tmp1[j] > K) { mi = max(mi,tmp1[j]-K); } mx = min(mx,tmp1[j]); } } if(mi <= mx && ok) { cout << "Yes" << "\n"; } else { cout << "No" << "\n"; } } }