#include <bits/stdc++.h>
using namespace std;
int gi() {
  char ch = '!';
  int res = 0, f = 0;
  while (ch < '0' || ch > '9') {
    ch = getchar();
    if (ch == '-') f = 1;
  }
  while (ch >= '0' && ch <= '9') res = res * 10 + ch - '0', ch = getchar();
  return f ? -res : res;
}
const int N = 1e5 + 100;
int n, m, p, K, h[N], a[N];
long long cur[N], add[N];
priority_queue<pair<long long, int> > Q;
bool check(long long val) {
  while (!Q.empty()) Q.pop();
  for (int i = 1; i <= n; ++i)
    cur[i] = val, add[i] = 0, Q.push(make_pair(-(val / a[i] + 1), i));
  long long now = 0, cnt = 0;
  while (!Q.empty() && -Q.top().first <= m) {
    int u = Q.top().second;
    long long nxt = -Q.top().first, c;
    Q.pop();
    if (now < nxt) now = nxt;
    c = (1ll * now * a[u] - cur[u] + p - 1) / p;
    cnt += c, cur[u] += c * p;
    if (cnt > (now - 1) * K) return 0;
    Q.push(make_pair(-(cur[u] / a[u] + 1), u));
  }
  for (int i = 1; i <= n; ++i) {
    long long tmp = (h[i] - (cur[i] - 1ll * m * a[i]) + p - 1) / p;
    if (tmp > 0) cnt += tmp;
    if (cnt > m * K) return 0;
  }
  return 1;
}
int main() {
  n = gi(), m = gi(), K = gi(), p = gi();
  for (int i = 1; i <= n; ++i) h[i] = gi(), a[i] = gi();
  long long l = -1, r = 1e15;
  while (l < r - 1) {
    long long mid = (l + r) >> 1;
    check(mid) ? r = mid : l = mid;
  }
  printf("%lld\n", r);
  return 0;
}
