#include <bits/stdc++.h>

#define FAST_IO ios::sync_with_stdio(false); cin.tie(0), cout << setprecision(15);
#define ll long long int
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, k, n) for (ll i = k; i>=n; i--)
#define repp(i, k, n) for (ll i = k; i < (n); i++)
#define pb push_back
#define all(x) begin(x), end(x)
#define vc vector<ll>
using namespace std;
using namespace std::chrono;
typedef std::chrono::high_resolution_clock Clock;
typedef std::chrono::milliseconds Milliseconds;

bool func(const array<ll, 2> &a, const array<ll, 2> &b) {
    if (a[0] > b[0]) return true;
    if (a[0] == b[0]) {
        if (a[1] < b[1]) {
            return true;
        }
    }
    return false;
}

bool fun(vc &arr, ll k, ll inc) {
    ll s = arr[0] + inc;
    repp(i, 1, arr.size()) {
        if (arr[i] * 100 > k * s) {
            return false;
        }
        s += arr[i];
    }
    return true;
}

void solve() {
    ll n, k;
    cin >> n >> k;
    vc arr(n);
    rep(i, n) cin >> arr[i];

    ll mid;
    ll low = 0;
    ll high = 2e14;
    while (low < high) {
        mid = (low + high) / 2;
        if (fun(arr, k, mid)) {
            high = mid;
        } else {
            low = mid + 1;
        }
    }
    ll ans = low;
    cout << ans << "\n";

}


void lc() {
    ll n;
    cin >> n;
    vc c(n);
    rep(i, n) cin >> c[i];
    vector<array<ll, 2>> arr(n);
    rep(i, n) {
        cin >> arr[i][0];
    }
    rep(i, n) {
        cin >> arr[i][1];
    }
    vector<bool> can(n, true);
    repp(i, 1, n) {
        ll a = arr[i - 1][0];
        ll b = arr[i - 1][1];
        if (max(a, b) < min(arr[i][0], arr[i][1]) || min(a, b) > max(arr[i][0], arr[i][1])) {
            can[i] = true;
        }
    }
    vc v(n, 0);
    rep(i, n) {
        ll a = arr[i][0];
        ll b = arr[i][1];
        if (i == 0) {
            v[i] = max(a, b) - min(a, b);
        } else {
            if (can[i]) {

            } else {

            }
        }
    }
}

void at() {
    ll n, s, d;
    cin>>n>>s>>d;
    vector<array<ll, 2>> arr(n);
    bool can = false;
    rep(i, n){
        cin>>arr[i][0]>>arr[i][1];
        if(arr[i][0]<s && arr[i][1]>d) can = true;
    }
    if(can) cout<<"Yes";
    else cout<<"No";
}

int main() {
    FAST_IO
    ll test = 1;
//    cin >> test;
    while (test-- > 0) {
        at();
    }
}
#include <bits/stdc++.h>
// #include <atcoder/all>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
// using namespace atcoder;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

ll a[MAX_N], b[MAX_N];
const ll INF = 1001001001001001001;
vector<int> G[MAX_N];

int main() {
    int n, m;
    cin >> n >> m;
    rep(i,n) cin >> a[i];
    rep(i,m){
        int x, y;
        cin >> x >> y;
        x--; y--;
        G[x].push_back(y);
    }

    ll ans = -INF;

    rep(i,n) b[i] = a[i];
    rep(i,n){
        rep(j,G[i].size()){
            int y = G[i][j];
            ans = max(ans, a[y] - b[i]);
            b[y] = min(b[y], b[i]);
        }
    }

    cout << ans << endl;
    return 0;
}


