#include <bits/stdc++.h>
const long long N = 1e5 + 51;
long long n, m, k, p, h[N], a[N];
struct T {
  long long x, i, l;
  bool operator>(const T& r) const {
    return (x + l * p) / a[i] > (r.x + r.l * p) / a[r.i];
  }
};
bool check(long long x) {
  fprintf(stderr, "mid = %lld\n", x);
  std::priority_queue<T, std::vector<T>, std::greater<T> > pq;
  for (long long i = 1; i <= n; i++)
    if (x - a[i] * m < h[i]) pq.push({x, i, 0});
  for (long long i = 1; i <= m; i++)
    for (long long j = 0; j < k; j++) {
      if (pq.empty()) return void(), true;
      T t = pq.top();
      pq.pop();
      if (t.x / a[t.i] < i) return void(), false;
      t.x += p;
      if (t.x - a[t.i] * m < h[t.i]) pq.push(t);
    }
  return pq.empty();
}
long long l, r;
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);
  for (l = 0, r = 1e18; l <= r;)
    if (check((l + r) / 2))
      r = (l + r) / 2 - 1;
    else
      l = (l + r) / 2 + 1;
  printf("%lld", l);
}
