#include <bits/stdc++.h>
using namespace std;
const long long N = 3e5 + 5;
long long read() {
  long long x = 0, f = 1;
  char ch;
  while (!isdigit(ch = getchar())) (ch == '-') && (f = -f);
  for (x = ch ^ 48; isdigit(ch = getchar());
       x = (x << 3) + (x << 1) + (ch ^ 48))
    ;
  return x * f;
}
template <class T>
T Max(T a, T b) {
  return a > b ? a : b;
}
template <class T>
T Min(T a, T b) {
  return a < b ? a : b;
}
struct node {
  long long day, id;
  bool friend operator<(node a, node b) { return a.day > b.day; }
};
priority_queue<node> q;
long long n, m, k, p, l, r, mid, h[N], a[N], c[N];
bool check(long long x) {
  while (!q.empty()) 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; !q.empty() && i <= m; ++i) {
    for (long long j = 1; !q.empty() && j <= k; ++j) {
      node u = q.top();
      q.pop();
      if (u.day < i) return 0;
      c[u.id]++;
      if (x + c[u.id] * p - a[u.id] * m < h[u.id])
        q.push((node){(x + c[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();
    l = max(l, a[i]);
    r = max(r, h[i] + a[i] * m);
  }
  while (l < r) {
    mid = (l + r) >> 1;
    if (check(mid))
      r = mid;
    else
      l = mid + 1;
  }
  printf("%lld\n", l);
  return 0;
}
