#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long 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 * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
long long n, m, k, p, a[200020];
long long h[200020];
long long nowh[200020];
struct node {
  long long cnt, id;
} u, v;
bool operator<(node a, node b) { return a.cnt > b.cnt; }
priority_queue<node> Q;
bool check(long long x) {
  while (!Q.empty()) Q.pop();
  for (long long i = 1; i <= n; i++) nowh[i] = 0;
  for (long long i = 1; i <= n; i++) {
    if (x - a[i] * m >= h[i]) continue;
    u.cnt = x / a[i], u.id = i;
    Q.push(u);
  }
  long long cnt = 0;
  for (long long i = 1; i <= m; i++)
    for (long long j = 1; j <= k; j++) {
      if (Q.empty()) break;
      u = Q.top();
      Q.pop();
      if (u.cnt < i) return false;
      nowh[u.id] += p;
      cnt++;
      if ((x + nowh[u.id] - (long long)a[u.id] * m) >= h[u.id]) continue;
      v.id = u.id, v.cnt = (x + nowh[u.id]) / a[u.id];
      Q.push(v);
    }
  return Q.empty();
}
int main() {
  n = read(), m = read(), k = read(), p = read();
  long long l = 0, r, ret;
  for (long long i = 1; i <= n; i++) {
    h[i] = read(), a[i] = read();
    r = max(r, a[i] * m + h[i]);
  }
  while (l <= r) {
    long long mid = (l + r) >> 1;
    if (check(mid))
      r = mid - 1, ret = mid;
    else
      l = mid + 1;
  }
  printf("%lld\n", ret);
}
