#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MN = 100100;
int n, m, k;
ll p, h[MN], a[MN];
ll h2[MN];
bool check(ll x) {
fill_n(h2, n, x);
priority_queue<P, vector<P>, greater<P>> q;
for (int i = 0; i < n; i++) {
if (h2[i] - m*a[i] >= 0) continue;
q.push(P(h2[i]/a[i]-1, i));
}
int count = 0;
for (; count < m*k; count++) {
if (q.empty()) break;
P hit = q.top(); q.pop();
if (hit.first < count/k) return false;
int i = hit.second;
h2[i] += p;
if (h2[i] - m*a[i] >= 0) continue;
q.push(P(h2[i]/a[i]-1, i));
}
if (count > m*k) return false;
for (int i = 0; i < n; i++) {
if (h2[i] - m*a[i] >= h[i]) continue;
count += (h[i] - (h2[i] - m*a[i]) + p-1) / p;
if (count > m*k) return false;
}
return true;
}
int main() {
cin >> n >> m >> k >> p;
for (int i = 0; i < n; i++) {
cin >> h[i] >> a[i];
}
ll l = 0, r = 1LL<<55;
while (r-l > 1) {
ll md = (l+r)/2;
if (check(md)) {
r = md;
} else {
l = md;
}
}
cout << r << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8cXVldWU+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwp0eXBlZGVmIGxvbmcgbG9uZyBsbDsKdHlwZWRlZiBwYWlyPGludCwgaW50PiBQOwoKY29uc3QgaW50IE1OID0gMTAwMTAwOwppbnQgbiwgbSwgazsKbGwgcCwgaFtNTl0sIGFbTU5dOwpsbCBoMltNTl07CmJvb2wgY2hlY2sobGwgeCkgewogICAgZmlsbF9uKGgyLCBuLCB4KTsKICAgIHByaW9yaXR5X3F1ZXVlPFAsIHZlY3RvcjxQPiwgZ3JlYXRlcjxQPj4gcTsKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgaSsrKSB7CiAgICAgICAgaWYgKGgyW2ldIC0gbSphW2ldID49IDApIGNvbnRpbnVlOwogICAgICAgIHEucHVzaChQKGgyW2ldL2FbaV0tMSwgaSkpOwogICAgfQogICAgaW50IGNvdW50ID0gMDsKICAgIGZvciAoOyBjb3VudCA8IG0qazsgY291bnQrKykgewogICAgICAgIGlmIChxLmVtcHR5KCkpIGJyZWFrOwogICAgICAgIFAgaGl0ID0gcS50b3AoKTsgcS5wb3AoKTsKICAgICAgICBpZiAoaGl0LmZpcnN0IDwgY291bnQvaykgcmV0dXJuIGZhbHNlOwogICAgICAgIGludCBpID0gaGl0LnNlY29uZDsKICAgICAgICBoMltpXSArPSBwOwogICAgICAgIGlmIChoMltpXSAtIG0qYVtpXSA+PSAwKSBjb250aW51ZTsKICAgICAgICBxLnB1c2goUChoMltpXS9hW2ldLTEsIGkpKTsKICAgIH0KICAgIGlmIChjb3VudCA+IG0qaykgcmV0dXJuIGZhbHNlOwogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyBpKyspIHsKICAgICAgICBpZiAoaDJbaV0gLSBtKmFbaV0gPj0gaFtpXSkgY29udGludWU7CiAgICAgICAgY291bnQgKz0gKGhbaV0gLSAoaDJbaV0gLSBtKmFbaV0pICsgcC0xKSAvIHA7CiAgICAgICAgaWYgKGNvdW50ID4gbSprKSByZXR1cm4gZmFsc2U7CiAgICB9CiAgICByZXR1cm4gdHJ1ZTsKfQoKaW50IG1haW4oKSB7CiAgICBjaW4gPj4gbiA+PiBtID4+IGsgPj4gcDsKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgaSsrKSB7CiAgICAgICAgY2luID4+IGhbaV0gPj4gYVtpXTsKICAgIH0KCiAgICBsbCBsID0gMCwgciA9IDFMTDw8NTU7CiAgICB3aGlsZSAoci1sID4gMSkgewogICAgICAgIGxsIG1kID0gKGwrcikvMjsKICAgICAgICBpZiAoY2hlY2sobWQpKSB7CiAgICAgICAgICAgIHIgPSBtZDsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBsID0gbWQ7CiAgICAgICAgfQogICAgfQogICAgY291dCA8PCByIDw8IGVuZGw7CiAgICByZXR1cm4gMDsKfQ==