#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10, MAXM = 1e4 + 10;
int n, m, li, p, t[MAXM];
long long a[MAXN], h[MAXN], b[MAXN];
int ok(long long x) {
  long long tt = 0;
  for (int i = 0; i < n; i++) tt += max(0LL, (h[i] + m * a[i] - x + p - 1) / p);
  if (tt > li * m) return 0;
  memset(t, 0, sizeof(t));
  long long x0;
  for (int i = 0; i < n; i++) {
    if (h[i] + m * a[i] < x) continue;
    x0 = (h[i] + m * a[i] - x) % p;
    if (!x0) x0 = p;
    for (long long j = x0; j <= h[i] + m * a[i] - x; j += p) {
      if (j < h[i])
        x0 = 0;
      else
        x0 = (j - h[i] + a[i] - 1) / a[i];
      if (x0 >= m) return 0;
      t[x0]++;
    }
  }
  int rest = 0;
  for (int i = 0; i < m; i++) {
    rest += t[i];
    rest = max(0, rest - li);
  }
  return rest == 0;
}
int main() {
  scanf("%d%d%d%d", &n, &m, &li, &p);
  long long mh = 0;
  for (int i = 0; i < n; i++) {
    scanf("%I64d%I64d", h + i, a + i);
    mh = max(mh, h[i] + m * a[i]);
  }
  for (long long l = 0, r = mh, mid;;) {
    if (r - l < 2) {
      printf("%I64d\n", r);
      break;
    }
    mid = (l + r) / 2;
    (ok(mid) ? r : l) = mid;
  }
  return 0;
}
