#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
const int N = 1e5 + 5;
int n, m, k, p;
int h[N], a[N], c[N];
inline bool check(long long mid) {
  memset(c, 0, 4 * (n + 1));
  priority_queue<pair<long long, int>, vector<pair<long long, int> >,
                 greater<pair<long long, int> > >
      q;
  for (int i = 1; i <= n; i++)
    if (mid - 1ll * m * a[i] < h[i]) q.push(make_pair(mid / a[i], i));
  for (int i = 1; !q.empty() && i <= m; i++) {
    for (int j = 1; !q.empty() && j <= k; j++) {
      pair<long long, int> x = q.top();
      q.pop();
      if (x.first < i) return 0;
      c[x.second]++;
      if (mid + 1ll * c[x.second] * p - 1ll * m * a[x.second] < h[x.second])
        q.push(
            make_pair((mid + 1ll * c[x.second] * p) / a[x.second], x.second));
    }
  }
  return q.empty();
}
int main() {
  n = read();
  m = read();
  k = read();
  p = read();
  long long l = 0, r = 0, ans = 0;
  for (int i = 1; i <= n; i++) {
    h[i] = read();
    a[i] = read();
    l = max(l, (long long)a[i]);
    r = max(r, 1ll * h[i] + 1ll * 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\n", ans);
  return 0;
}
