#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e5 + 5;
struct Node {
  long long day, id;
  bool operator<(const Node &b) const { return day > b.day; }
};
priority_queue<Node> q;
long long n, m, k, p;
long long h[MAXN], a[MAXN];
long long c[MAXN];
long long l, r;
inline long long read() {
  long long tot = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    tot = tot * 10 + c - '0';
    c = getchar();
  }
  return tot * f;
}
inline bool check(long long x) {
  while (q.size()) q.pop();
  memset(c, 0, sizeof(c));
  for (long long i = 1; i <= n; i++)
    if (x - a[i] * m < h[i]) q.push((Node){x / a[i], i});
  for (long long i = 1; i <= m && q.size(); i++)
    for (long long j = 1; j <= k && q.size(); j++) {
      Node now = q.top();
      q.pop();
      if (now.day < i) return 0;
      c[now.id]++;
      if (x + c[now.id] * p - a[now.id] * m < h[now.id])
        q.push((Node){(x + c[now.id] * p) / a[now.id], now.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] + m * a[i]);
  }
  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\n", ans);
  return 0;
}
