#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() {
  long long x = 0;
  char ch = getchar();
  bool positive = 1;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') positive = 0;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  return positive ? x : -x;
}
inline void write(long long a) {
  if (a < 0) {
    a = -a;
    putchar('-');
  }
  if (a >= 10) write(a / 10);
  putchar('0' + a % 10);
}
inline void writeln(long long a) {
  write(a);
  puts("");
}
inline void wri(long long a) {
  write(a);
  putchar(' ');
}
const long long N = 100005;
priority_queue<pair<long long, long long> > q;
long long n, m, k, p, b[N], h[N], a[N];
bool check(long long x) {
  long long sum = 0;
  while (q.size()) q.pop();
  for (long long i = 1; i <= n; i++) {
    b[i] = 0;
    q.push(make_pair(m - x / a[i], i));
  }
  for (long long i = m; i; i--) {
    if (q.top().first >= i) return 0;
    for (long long j = 0; j < k; j++) {
      if (q.top().first <= 0) {
        sum += k - j;
        break;
      }
      long long t = q.top().second;
      q.pop();
      b[t]++;
      q.push(make_pair(m - (x + b[t] * p) / a[t], t));
    }
  }
  for (long long i = 1; i <= n; i++)
    if (h[i] >= x + b[i] * p - a[i] * m)
      sum -= (h[i] - (x + b[i] * p - a[i] * m) + p - 1) / p;
  return sum >= 0;
}
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 = 1e14 + 1e9;
  while (l < r) {
    long long mid = (l + r) >> 1;
    if (check(mid))
      r = mid;
    else
      l = mid + 1;
  }
  cout << l << endl;
}
