#include <bits/stdc++.h>
using namespace std;
inline long long in() {
  long long x = 0;
  bool f = 0;
  char c;
  for (; (c = getchar()) < '0' || c > '9'; f = c == '-')
    ;
  for (x = c - '0'; (c = getchar()) >= '0' && c <= '9';
       x = (x << 3) + (x << 1) + c - '0')
    ;
  return f ? -x : x;
}
priority_queue<pair<long long, int>, vector<pair<long long, int> >,
               greater<pair<long long, int> > >
    q;
long long h[100005], a[100005], cur[100005];
long long n, m, k, p, mx, res;
inline bool check(long long x) {
  while (!q.empty()) q.pop();
  for (int i = 1; i <= n; ++i) {
    cur[i] = x;
    if (x - m * a[i] < 0) q.push(make_pair(cur[i] / a[i], i));
  }
  long long cnt = 0;
  for (cnt = 0; cnt <= m * k; ++cnt) {
    if (q.empty()) break;
    pair<long long, int> y = q.top();
    q.pop();
    long long v = y.first;
    int u = y.second;
    if (v <= cnt / k) return 0;
    cur[u] += p;
    if (cur[u] - m * a[u] < 0) q.push(make_pair(cur[u] / a[u], u));
  }
  if (cnt > m * k) return 0;
  for (int i = 1; i <= n; ++i) {
    long long t = h[i] - cur[i] + m * a[i];
    if (t > 0) cnt += (t / p) + ((bool)(t % p));
    if (cnt > m * k) return 0;
  }
  return 1;
}
int main() {
  n = in();
  m = in();
  k = in();
  p = in();
  for (int i = 1; i <= n; ++i) {
    h[i] = in();
    a[i] = in();
    mx = max(mx, h[i] + m * a[i]);
  }
  long long l = 0ll, r = mx;
  while (l <= r) {
    long long mid = (l + r) >> 1ll;
    if (check(mid))
      res = mid, r = mid - 1ll;
    else
      l = mid + 1ll;
  }
  printf("%I64d", res);
  return 0;
}
