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