#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 10;
const double eps = 1e-12;
int n, m, a[maxn], h[maxn], k, ned[maxn], p;
long long f[maxn], l, r, ans, t[maxn];
long long up(double x) {
  long long v = (long long)x;
  if (fabs(x - v) > eps)
    return v + 1;
  else
    return v;
}
bool check(long long lim) {
  for (int i = 1; i <= n; i++)
    t[i] = max((long long)0, (f[i] - lim + p - 1) / p);
  long long cnt = 0;
  for (int i = 1; i <= n; i++) cnt += t[i];
  if (cnt > m * k) return 0;
  memset(ned, 0, sizeof(ned));
  for (int i = 1; i <= n; i++) {
    if (!t[i]) continue;
    for (long long j = (f[i] - lim - 1 + p) % p + 1; j <= f[i] - lim; j += p) {
      if (j <= h[i])
        ned[0]++;
      else if (j > f[i] - a[i])
        return 0;
      else {
        long long pos = up((j - h[i]) / (double)a[i]);
        ned[pos]++;
      }
    }
  }
  int hm = 0;
  for (int i = 0; i < m; i++) {
    hm += ned[i];
    hm = max(0, hm - k);
  }
  return hm == 0;
}
int main() {
  scanf("%d%d%d%d", &n, &m, &k, &p);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &h[i], &a[i]);
    f[i] = (long long)m * a[i] + h[i];
    l = max(l, (long long)a[i]);
    r = max(r, f[i]);
  }
  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;
}
