#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100100;
long long h[MAXN], a[MAXN];
int cnt[MAXN];
int n, m, k, p;
bool can(long long H) {
  long long sum = 0;
  for (int i = (0); i < (m + 1); ++i) cnt[i] = 0;
  for (int i = (0); i < (n); ++i) {
    if (h[i] + m * a[i] <= H) continue;
    if (a[i] > H) return false;
    int j = m;
    long long cur = H;
    while (j > 0) {
      if (cur - j * a[i] >= h[i]) break;
      long long w = min(cur / a[i], (long long)j);
      long long delta = a[i] - (cur - w * a[i]);
      if (w == j) delta = h[i] - (cur - w * a[i]);
      long long need = (delta + p - 1) / p;
      sum += need;
      cnt[j - w + 1] += need;
      if (sum > m * k) return false;
      j -= w;
      cur += need * p - w * a[i];
    }
  }
  int cur = 0;
  for (int i = (1); i < (m + 1); ++i) {
    cur += cnt[i];
    cur = max(cur - k, 0);
  }
  return cur == 0;
}
int main(void) {
  scanf("%d %d %d %d", &n, &m, &k, &p);
  for (int i = (0); i < (n); ++i) scanf("%lld %lld", h + i, a + i);
  long long lo = 0, hi = 2e18;
  while (lo < hi) {
    long long mid = (lo + hi) / 2;
    if (can(mid))
      hi = mid;
    else
      lo = mid + 1;
  }
  printf("%lld\n", lo);
  return 0;
}
