#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long ret = 0, t = 1;
  char c = getchar();
  while ((c < '0' || c > '9') && c != '-') c = getchar();
  if (c == '-') t = -1, c = getchar();
  while (c >= '0' && c <= '9') ret = ret * 10 + c - '0', c = getchar();
  return ret * t;
}
const long long MAXN = 100100;
long long n, m, k, p;
long long h[MAXN], a[MAXN], cnt[MAXN];
long long ceil(long long x, long long y) { return x / y + (x % y ? 1 : 0); }
struct qwq {
  long long und, id;
  bool operator<(const qwq &x) const { return x.und < und; }
};
priority_queue<qwq> q;
bool check(long long x) {
  long long i, j;
  while (!q.empty()) q.pop();
  for (i = 1; i <= n; i++) cnt[i] = 0;
  for (i = 1; i <= n; i++)
    if (x - m * a[i] < h[i]) q.push({x / a[i], i});
  for (i = 1; i <= m; i++)
    for (j = 1; j <= k; j++) {
      if (!q.empty()) {
        qwq f = q.top();
        q.pop();
        if (f.und < i) return false;
        ++cnt[f.id];
        if (x + cnt[f.id] * p - m * a[f.id] < h[f.id])
          q.push({(x + cnt[f.id] * p) / a[f.id], f.id});
      }
    }
  return q.empty();
}
signed main() {
  n = read(), m = read(), k = read(), p = read();
  long long i, j;
  long long L = 0, R = 1e18, ans;
  for (i = 1; i <= n; i++)
    h[i] = read(), a[i] = read(), L = max(L, (long long)(a[i]));
  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;
}
