#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5;
const long long M = 21;
const long long maxn = 5e6 + 5;
const long long mod = 1e9 + 7;
const long long inf = 0x3f3f3f3f3f3f3f3f;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline long long ksm(long long x, long long y = mod - 2, long long z = mod) {
  long long ret = 1;
  while (y) {
    if (y & 1) ret = (ret * x) % z;
    x = (x * x) % z;
    y >>= 1;
  }
  return ret;
}
long long n, m, k, p, ans, l, r;
long long a[N], h[N];
struct Node {
  long long day, id;
  bool operator<(const Node& o) const { return day > o.day; }
};
priority_queue<Node> Q;
long long cnt[N];
bool chk(long long x) {
  while (!Q.empty()) Q.pop();
  for (long long i = 1; i <= n; i++) cnt[i] = 0;
  for (long long i = 1; i <= n; i++)
    if (x < h[i] + a[i] * m) Q.push((Node){x / a[i], i});
  for (long long i = 1; i <= m; i++)
    for (long long j = 1; j <= k; j++) {
      if (Q.empty()) return 1;
      Node u = Q.top();
      Q.pop();
      if (u.day < i) return 0;
      cnt[u.id]++;
      if (x + cnt[u.id] * p < h[u.id] + a[u.id] * m)
        Q.push((Node){(x + cnt[u.id] * p) / a[u.id], u.id});
    }
  return Q.empty();
}
signed main() {
  n = read();
  m = read();
  k = read();
  p = read();
  for (long long i = 1; i <= n; i++) {
    h[i] = read();
    a[i] = read();
    r = max(r, h[i] + a[i] * m);
  }
  while (l <= r) {
    long long mid = (l + r) / 2;
    if (chk(mid))
      ans = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  cout << ans << endl;
}
