#include <bits/stdc++.h>
using namespace std;
const int kMaxN = 100000, kMaxM = 5000;
int n, m, k, p;
int h[kMaxN], a[kMaxN];
long long rec[kMaxN], ex[kMaxN];
int cnt[kMaxM];
bool check(long long lim) {
  long long tot = 0;
  for (int i = 0; i < n; ++i) {
    ex[i] = h[i] + (long long)m * a[i];
    if (ex[i] > lim) {
      tot += rec[i] = (ex[i] - lim - 1) / p + 1;
    } else {
      rec[i] = 0;
    }
  }
  if (tot > (long long)m * k) return false;
  memset(cnt, 0, sizeof(cnt));
  for (int i = 0; i < n; ++i) {
    int t = rec[i];
    if (!t) continue;
    for (long long j = (ex[i] - lim) % p == 0 ? p : (ex[i] - lim) % p;
         j <= ex[i] - lim; j += p) {
      if (h[i] >= j) {
        ++cnt[0];
      } else {
        int _ = (j - h[i] - 1) / a[i] + 1;
        if (_ >= m) return false;
        ++cnt[_];
      }
    }
  }
  int tmp = 0;
  for (int i = 0; i < m; ++i) {
    tmp += cnt[i];
    tmp -= k;
    if (tmp < 0) {
      tmp = 0;
    }
  }
  return (tmp == 0);
}
int main() {
  scanf("%d%d%d%d", &n, &m, &k, &p);
  long long lb = 0, rb = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &h[i], &a[i]);
    lb = max(lb, (long long)a[i]);
    rb = max(rb, (long long)h[i] + (long long)m * a[i]);
  }
  --lb;
  while (lb + 1 < rb) {
    long long mid = (lb + rb) >> 1;
    if (check(mid)) {
      rb = mid;
    } else {
      lb = mid;
    }
  }
  printf("%I64d\n", rb);
  return 0;
}
