#include <bits/stdc++.h>
using namespace std;
const long long N = 100005;
const long long MAX = (1LL << 55);
long long n, m, k, p;
long long h[N], a[N];
priority_queue<pair<long long, pair<long long, long long> >,
               vector<pair<long long, pair<long long, long long> > >,
               greater<pair<long long, pair<long long, long long> > > >
    s;
inline long long read() {
  long long f = 1, x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
bool check(long long x) {
  while (!s.empty()) s.pop();
  for (long long u = 1; u <= n; u++) {
    if (x < a[u]) return false;
    s.push({x / a[u], {u, x}});
  }
  long long tot = 0;
  for (long long u = 1; u < m; u++) {
    while (true) {
      pair<long long, pair<long long, long long> > x = s.top();
      if (x.first == u) {
        long long now = x.second.second;
        long long id = x.second.first;
        now = now % a[id];
        long long need = (a[id] - now + p - 1) / p;
        tot = tot + need;
        if (tot > u * k) return false;
        now = now + need * p;
        s.pop();
        s.push({x.first + now / a[id], {id, now}});
      } else
        break;
    }
    if (tot > u * k) return false;
  }
  while (!s.empty()) {
    pair<long long, pair<long long, long long> > x = s.top();
    s.pop();
    long long now = x.second.second;
    long long id = x.second.first;
    long long nxt = x.first;
    now = now % a[id];
    now = now + (nxt - m) * a[id];
    if (now >= h[id]) continue;
    long long need = (h[id] - now + p - 1) / p;
    tot = tot + need;
  }
  if (tot > m * k) return false;
  return true;
}
int main() {
  n = read();
  m = read();
  k = read();
  p = read();
  for (long long u = 1; u <= n; u++) {
    h[u] = read();
    a[u] = read();
  }
  long long l = 0, r = MAX, ans = 0;
  while (l <= r) {
    long long mid = (l + r) >> 1;
    if (check(mid)) {
      ans = mid;
      r = mid - 1;
    } else
      l = mid + 1;
  }
  printf("%I64d\n", ans);
  return 0;
}
