#include <bits/stdc++.h>
using namespace std;
struct node {
  long long w, id;
  node() {}
  node(long long W, long long Id) { w = W, id = Id; }
  bool operator<(const node &t) const { return w > t.w; }
};
priority_queue<node> q;
long long n, m, k, p, l, r, ans;
long long h[100005], a[100005], tot[100005];
bool check(long long x) {
  while (!q.empty()) q.pop();
  memset(tot, 0, sizeof(tot));
  for (long long i = 1; i <= n; i++)
    if (h[i] + a[i] * m > x) q.push(node(x / a[i], i));
  for (long long i = 1; i <= m && !q.empty(); i++) {
    for (long long j = 1; j <= k && !q.empty(); j++) {
      node t = q.top();
      q.pop();
      if (t.w < i) return 0;
      tot[t.id]++;
      if (h[t.id] + a[t.id] * m - tot[t.id] * p > x)
        q.push(node((x + tot[t.id] * p) / a[t.id], t.id));
    }
  }
  return q.empty();
}
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]);
    r = max(r, h[i] + a[i] * m);
  }
  while (l <= r) {
    long long mid = (l + r) >> 1;
    if (check(mid))
      ans = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  printf("%lld", ans);
  return 0;
}
