#include <bits/stdc++.h>
using namespace std;
const int L_N = 1e5 + 10;
const int L_M = 5000 + 10;
int N, M, K;
long long P, A[L_N], H[L_N];
long long need[L_N], rem[L_N], t[L_M];
void nxt(long long& day, long long& hei, long long add, long long dst) {
  long long ad = (dst - hei) / add;
  if (dst > hei && (dst - hei) % add) ad++;
  if (dst < hei) ad = 0;
  day += ad;
  hei += ad * add;
  hei -= dst;
  if (day > M) day = -1;
}
bool check(long long x) {
  long long tot = 0;
  for (int i = 1; i <= N; i++) {
    long long dec = A[i] + H[i] * M - x;
    if (dec <= 0) {
      need[i] = rem[i] = 0;
    } else {
      need[i] = dec / P;
      if (dec % P) need[i]++;
      rem[i] = dec % P;
      tot += need[i];
    }
    if (x < H[i]) return false;
  }
  if (tot > M * K) return false;
  memset(t, 0, sizeof(t));
  for (int i = 1; i <= N; i++) {
    long long day = 1, hei = A[i];
    if (rem[i]) {
      nxt(day, hei, H[i], rem[i]);
      if (day < 0) return false;
      t[day]++, need[i]--;
    }
    while (need[i]) {
      nxt(day, hei, H[i], P);
      if (day < 0) return false;
      t[day]++, need[i]--;
    }
  }
  int rest = 0;
  for (int i = 1; i <= M; i++) {
    rest += t[i];
    rest = max(0, rest - K);
  }
  if (rest)
    return false;
  else
    return true;
}
int main() {
  scanf("%d %d %d %I64d", &N, &M, &K, &P);
  for (int i = 1; i <= N; i++) scanf("%I64d %I64d", &A[i], &H[i]);
  long long l = 0, r = 2e13;
  while (l < r) {
    long long mid = (l + r) / 2;
    if (check(mid))
      r = mid;
    else
      l = mid + 1;
  }
  printf("%I64d\n", l);
  return 0;
}
