#include <bits/stdc++.h>
using namespace std;
long long n, m, k, p, a[100000 + 1], b[100000 + 1], h[100000 + 1],
    rt[100000 + 1], cnt[5000 + 1];
long long read() {
  char c = 0;
  long long sum = 0;
  while (c < '0' || c > '9') c = getchar();
  while ('0' <= c && c <= '9') sum = sum * 10 + c - '0', c = getchar();
  return sum;
}
long long find(long long x) {
  if (rt[x] == x) return x;
  return rt[x] = find(rt[x]);
}
void unionn(long long x, long long y) {
  if (x != y) rt[x] = y;
  return;
}
bool check(long long x) {
  long long t, pt;
  for (long long i = 1; i <= m; ++i) cnt[i] = k, rt[i] = i;
  long long res, tot, ps;
  for (long long i = 1; i <= n; ++i) {
    if (x < a[i]) return 0;
    t = x, res = 0;
    while (1) {
      pt = t;
      res += t / a[i], t %= a[i];
      if (res >= m) {
        b[i] = pt - (m - (res - pt / a[i])) * a[i];
        break;
      }
      while (t < a[i]) {
        ps = find(res);
        if (ps == 0) return 0;
        cnt[ps]--, t += p;
        if (cnt[ps] == 0) unionn(ps, ps - 1);
      }
    }
  }
  tot = res = 0;
  for (long long i = 1; i <= m; ++i) tot += cnt[i];
  for (long long i = 1; i <= n; ++i)
    if (b[i] < h[i]) res += ceil(1.0 * (h[i] - b[i]) / p);
  if (res > tot) return 0;
  return 1;
}
signed main() {
  n = read(), m = read(), k = read(), p = read();
  for (long long i = 1; i <= n; ++i) h[i] = read(), a[i] = read();
  long long first = 0, last = 1e13, mid, ans = 1e13;
  while (first <= last) {
    mid = (first + last) / 2;
    if (check(mid))
      last = mid - 1, ans = min(ans, mid);
    else
      first = mid + 1;
  }
  printf("%lld\n", ans);
  return 0;
}
