#include <bits/stdc++.h>
using namespace std;
inline char gc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline long long read() {
  char c = getchar();
  long long tot = 1;
  while ((c < '0' || c > '9') && c != '-') c = getchar();
  if (c == '-') {
    tot = -1;
    c = getchar();
  }
  long long sum = 0;
  while (c >= '0' && c <= '9') {
    sum = sum * 10 + c - '0';
    c = getchar();
  }
  return sum * tot;
}
inline void wr(long long x) {
  if (x < 0) {
    putchar('-');
    wr(-x);
    return;
  }
  if (x >= 10) wr(x / 10);
  putchar(x % 10 + '0');
}
inline void wrn(long long x) {
  wr(x);
  putchar('\n');
}
inline void wri(long long x) {
  wr(x);
  putchar(' ');
}
inline void wrn(long long x, long long y) {
  wri(x);
  wrn(y);
}
inline void wrn(long long a, long long b, long long c) {
  wri(a);
  wrn(b, c);
}
long long n, m, f[500055], h[500055], a[500055], k, r, p;
priority_queue<pair<long long, long long>, vector<pair<long long, long long> >,
               greater<pair<long long, long long> > >
    q;
bool check(long long x) {
  while (!q.empty()) q.pop();
  for (long long i = (1); i <= (n); i++) f[i] = x;
  for (long long i = (1); i <= (n); i++) {
    if (x - a[i] * m >= 0) continue;
    q.push(make_pair(x / a[i] - 1, i));
  }
  long long tot = 0;
  for (; tot <= m * k; tot++) {
    if (q.empty()) break;
    pair<long long, long long> t = q.top();
    q.pop();
    if (t.first < tot / k) return 0;
    f[t.second] += p;
    if (f[t.second] - m * a[t.second] >= 0) continue;
    q.push(make_pair(f[t.second] / a[t.second] - 1, t.second));
  }
  for (long long i = (1); i <= (n); i++) {
    if (f[i] - m * a[i] >= h[i]) continue;
    tot += (h[i] - (f[i] - m * a[i]) + p - 1) / p;
  }
  return (tot <= m * k);
}
signed main() {
  n = read();
  m = read();
  k = read();
  p = read();
  for (long long i = (1); i <= (n); i++) h[i] = read(), a[i] = read();
  long long l = 0, r = 1e15;
  while (l < r) {
    long long mid = (l + r) >> 1;
    if (check(mid))
      r = mid;
    else
      l = mid + 1;
  }
  wrn(l);
  return 0;
}
