#include <bits/stdc++.h>
using namespace std;
int n, m, k, p, H[100000 + 5], A[100000 + 5], T[5000 + 5];
long long l, r, Final[100000 + 5];
inline bool Check(long long lim) {
  long long tot = 0;
  for (int i = 1; i <= n; i++) tot += max(0LL, (Final[i] - lim + p - 1) / p);
  if (tot > m * k) return 0;
  memset(T, 0, sizeof(T));
  for (int i = 1; i <= n; i++) {
    if (Final[i] <= lim) continue;
    for (long long t = (Final[i] - lim - 1) % p + 1; t <= Final[i] - lim;
         t += p) {
      if (t <= H[i])
        T[0]++;
      else if (t > Final[i] - A[i])
        return 0;
      else
        T[(t - H[i] + A[i] - 1) / A[i]]++;
    }
  }
  int ret = 0;
  for (int i = 0; i < m; i++) {
    ret += T[i];
    ret = max(0, ret - k);
  }
  return ret == 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);
    l = max(l, (long long)A[i]);
    r = max(r, Final[i] = 1LL * m * A[i] + H[i]);
  }
  while (l < r) {
    long long mid = l + r >> 1;
    if (Check(mid))
      r = mid;
    else
      l = mid + 1;
  }
  printf("%I64d\n", l);
  return 0;
}
