#include <bits/stdc++.h>
using namespace std;
long long n, m, k, p;
long long h[100003], a[100003], w[100003];
struct XXX {
  long long val, id;
  friend bool operator<(const XXX &X, const XXX &Y) { return X.val > Y.val; }
};
bool che(long long x) {
  priority_queue<XXX> q;
  for (long long i = 1; i <= n; i++) {
    w[i] = x;
    if (x - a[i] * m < h[i]) q.push((XXX){x / a[i], i});
  }
  for (long long i = 1; i <= m && !q.empty(); i++)
    for (long long j = 1; j <= k && !q.empty(); j++) {
      struct XXX t = q.top();
      q.pop();
      if (w[t.id] - a[t.id] * i < 0) return 0;
      w[t.id] += p;
      if (w[t.id] - a[t.id] * m < h[t.id])
        q.push((XXX){w[t.id] / a[t.id], t.id});
    }
  for (long long i = 1; i <= n; i++)
    if (w[i] - a[i] * m < h[i]) return 0;
  return 1;
}
int main() {
  long long l = 0, r = 0, mid;
  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 = max(l, a[i]);
    r = max(r, h[i] + m * a[i]);
  }
  while (l < r) {
    long long mid = (l + r) / 2;
    if (che(mid))
      r = mid;
    else
      l = mid + 1;
  }
  printf("%lld", l);
  return 0;
}
