#include <bits/stdc++.h>
using namespace std;
int N, M, K, P;
long long h[100000], a[100000];
vector<int> news[5000];
int bit[5010];
int read(int idx) {
  idx += 3;
  int ans = 0;
  for (int i = idx; i > 0; i -= i & -i) ans += bit[i];
  return ans;
}
void update(int idx) {
  idx += 3;
  for (int i = idx; i < 5010; i += i & -i) bit[i]++;
}
int cuts;
bool put(int idx) {
  if (++cuts > M * K) return true;
  if (idx >= M) return true;
  update(idx);
  return false;
}
bool ok(long long target) {
  for (int i = (0); i < (5010); i++) bit[i] = 0;
  cuts = 0;
  for (int i = (0); i < (N); i++) {
    long long v = h[i] + a[i] * M;
    if (v > target) {
      v -= target;
      long long needed = v / P;
      long long margin = v % P;
      long long ch = h[i];
      if (margin) {
        if (h[i] >= margin) {
          if (put(0)) return false;
        } else {
          if (put((margin - h[i] + a[i] - 1) / a[i])) return false;
        }
        ch -= margin;
      }
      int ct = 0;
      while (needed) {
        if (ct >= M) return false;
        while (ch >= P && needed) {
          if (put(ct)) return false;
          ch -= P;
          needed--;
        }
        long long diff = (P - ch + a[i] - 1) / a[i];
        ch += diff * a[i];
        ct += diff;
      }
    }
  }
  int total = read(M - 1);
  for (int i = (0); i < (M); i++) {
    if (total - read(i - 1) > (M - i) * K) return false;
  }
  return true;
}
int main() {
  scanf("%d", &(N));
  scanf("%d", &(M));
  scanf("%d", &(K));
  scanf("%d", &(P));
  long long lo = 0;
  for (int i = (0); i < (N); i++) {
    scanf("%lld", &(h[i]));
    scanf("%lld", &(a[i]));
    lo = max(lo, a[i]);
  }
  long long hi = (long long)1e15;
  while (lo < hi) {
    long long mid = (lo + hi) / 2;
    if (ok(mid))
      hi = mid;
    else
      lo = mid + 1;
  }
  printf("%lld\n", lo);
}
