#include <bits/stdc++.h>
const long long N = 100005;
long long n, m, k, p, h[N], a[N], l, r, c[N];
bool check(long long x) {
  std::priority_queue<std::pair<long long, long long> > q;
  for (long long i = 1; i <= n; i++) {
    if (h[i] + m * a[i] <= x) continue;
    q.push(std::make_pair(-(x / a[i]), i)), c[i] = 0;
  }
  long long cnt = 0;
  for (long long i = 1; !q.empty() && i <= m; i++)
    for (long long j = 1; !q.empty() && j <= k; j++) {
      if (-q.top().first < i) return 0;
      long long t = q.top().second;
      q.pop();
      long long w = (x + (++c[t]) * p) / a[t];
      if (w < m) q.push(std::make_pair(-w, t));
      ++cnt;
    }
  for (long long i = 1; i <= n; i++) {
    long long w = x + c[i] * p - m * a[i];
    if (h[i] <= w) continue;
    w = (h[i] - w - 1) / p + 1;
    if (cnt + w > m * k) return false;
    cnt += w;
  }
  return true;
}
signed main() {
  scanf("%lld%lld%lld%lld", &n, &m, &k, &p);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld%lld", &h[i], &a[i]);
    l = std::max(l, a[i]), r = std::max(r, h[i] + m * a[i]);
  }
  long long ans = 0;
  while (l <= r) {
    long long mid = l + (r - l) / 2;
    if (check(mid))
      r = mid - 1, ans = mid;
    else
      l = mid + 1;
  }
  printf("%lld", ans);
  return 0;
}
