#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <iomanip>
using namespace std;

#define rep(i, N) for (int i = 0; i < N; i++)
#define repi(i, ini, N) for(int i = ini; i < N; i++)
#define chmax(i, j) i = max(i, j)
#define chmin(i, j) i = min(i, j)
typedef long long ll;

ll N;
ll K;

int main() {
    cin >> N >> K;
    vector<pair<ll, ll> > A;
    rep(i, N) {
        ll a, b;
        cin >> a >> b;
        A.push_back(make_pair(a,b));
    }
    sort(A.begin(), A.end());
    ll now = 0;
    rep(i, N) {
        if (A[i].first > now+K) {
            cout << now+K << endl;
            return 0;
        }
        K = K - (A[i].first-now);
        now = A[i].first;
        K += A[i].second;
    }
    cout << now + K << endl;

}
#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> used(2 * N);
  auto out = []() {
    cout << "No" << endl;
    exit(0);
  };
  REP(i, N) {
    int A, B;
    cin >> A >> B;
    if (A != -1 && B != -1 && A >= B) out();
    if (A != -1) {
      if (used[A - 1] != 0) out();
      used[A - 1] = i + 1;
    }
    if (B != -1) {
      if (used[B - 1] != 0) out();
      used[B - 1] = -(i + 1);
    }
  }
  vector<bool> dp(N + 1);
  dp[0] = 1;
  FOR(i, 1, N + 1) {
    REP(j, i)
    if (dp[j]) {
      bool ng = 0;
      REP(k, i - j) {
        int a = used[2 * j + k], b = used[2 * j + k + i - j];
        ng |= (a < 0) || (b > 0) || (a > 0 && b < 0 && b != -a);
      }
      if (!ng) {
        dp[i] = 1;
        break;
      }
    }
  }
  cout << (dp[N] ? "Yes" : "No") << endl;
  return 0;
}