#include "bits/stdc++.h"
#define puba push_back
#define mapa make_pair
#define ff first
#define ss second
#define bend(_x) (_x).begin(), (_x).end()
#define szof(_x) ((int) (_x).size())

using namespace std;
typedef long long ll;
typedef double dbl;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <long long, long long> pll;
const int MAXN = 1e5 + 5;

int n, m, k;
vector <pii> places;
vector <int> arrx;
vector <int> busy[MAXN];
int xb, yb;

ll ans = 8e18;

int try_set(int c, int start) {
    //cerr << c << " " << start << endl;
    ll now = (ll) abs(c - xb) * k;
    //cerr << now << endl;
    if (start < yb) {
        now += (ll) (yb - start) * (yb - start + 1) / 2;
    }
    if (start + k - 1 > yb) {
        now += (ll) (start + k - 1 - yb) * (start + k - 1 - yb + 1) / 2;
    }
    ans = min(ans, now);
    return 0;
}

int solve(int c) {
    //cerr << "solve: " << c << endl;
    int pos = lower_bound(bend(arrx), c) - arrx.begin();
    
    int prev = -1;
    for (int i = 0; i < szof(busy[pos]); ++i) {
        //cerr << busy[pos][i] - prev - 1 << endl;
        if (busy[pos][i] - prev - 1 >= k) {
            //cerr << "#" << endl;
            try_set(c, prev + 1);
            try_set(c, busy[pos][i] - k);
        }
        prev = busy[pos][i];
    }
    //cerr << n << " " << prev << endl;
    if (n - prev - 1 >= k) {
        //cerr << "@" << endl;
        try_set(c, prev + 1);
        try_set(c, n - k);
    }
    int start = yb - k / 2;
    if (start >= 0 && start + k - 1 <= n - 1 && *lower_bound(bend(busy[pos]), start) > start + k - 1) {
        try_set(c, start);
    }
    if (k % 2 == 0) {
        ++start;
        if (start >= 0 && start + k - 1 <= n - 1 && *lower_bound(bend(busy[pos]), start) > start + k - 1) {
            try_set(c, start);
        }
    }    

    return 0;
}

int main() {    
    freopen("cinema.in", "r", stdin);
    freopen("cinema.out", "w", stdout);

    cin >> n >> m >> k;

    for (int i = 0; i < m; ++i) {
        int x, y;
        cin >> x >> y;
        --x;--y;
        places.puba(mapa(x, y));
        arrx.puba(x);
    }

    sort(bend(arrx));
    arrx.resize(unique(bend(arrx)) - arrx.begin());

    for (int i = 0; i < m; ++i) {
        busy[lower_bound(bend(arrx), places[i].ff) - arrx.begin()].puba(places[i].ss);
    }

    for (int i = 0; i < szof(arrx); ++i) {
        sort(bend(busy[i]));
    }    

    cin >> xb >> yb;
    --xb;--yb;

    //cerr << xb << " " << yb << endl;
    
    int c = xb;

    for (; c >= 0; --c) {
        if (*lower_bound(bend(arrx), c) != c) {
            int start = yb - k / 2;
            if (start < 0) {
                start = 0;
            }
            if (start + k - 1 > n - 1) {
                start = n - k;
            }
            try_set(c, start);
            break;
        }
        solve(c);
    }

    cerr << xb << " " << c << endl;

    c = xb;

    for (; c < n; ++c) {
        if (*lower_bound(bend(arrx), c) != c) {
            int start = yb - k / 2;
            if (start < 0) {
                start = 0;
            }
            if (start + k - 1 > n - 1) {
                start = n - k;
            }
            try_set(c, start);
            break;
        }
        solve(c);
    }

    cerr << xb << " " << c << endl;

    if (ans == 8e18) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }

    return 0;
}