#include <bits/stdc++.h>
using namespace std;
long long n, m, k, p, cnt[200005], l[200005], h[200005], a[200005], head, tail,
    mid, ans;
int check(long long x) {
  long long tot = 0;
  for (int i = 1; i <= n; i++)
    l[i] = h[i] + a[i] * m,
    tot += (0ll > (l[i] - x + p - 1) / p ? 0ll : (l[i] - x + p - 1) / p);
  if (tot > m * k) return 0;
  for (int i = 0; i <= m; i++) cnt[i] = 0;
  for (int i = 1; i <= n; i++) {
    if (l[i] > x) {
      for (long long u = (l[i] - x - 1) % p + 1; u <= l[i] - x; u += p) {
        if (u <= h[i]) {
          cnt[0]++;
          continue;
        }
        if (u > h[i] + a[i] * (m - 1)) return 0;
        cnt[(u - h[i] + a[i] - 1) / a[i]]++;
      }
    }
  }
  int ma = 0;
  for (int i = 0; i <= m - 1; i++) ma += cnt[i], ma = (0 > ma - k ? 0 : ma - k);
  return !ma;
}
int main() {
  scanf("%lld%lld%lld%lld", &n, &m, &k, &p);
  for (int i = 1; i <= n; i++) scanf("%lld%lld", &h[i], &a[i]);
  head = 0, tail = 1e15;
  while (head <= tail) {
    mid = (head + tail) >> 1;
    if (check(mid))
      ans = mid, tail = mid - 1;
    else
      head = mid + 1;
  }
  printf("%lld", ans);
}
