#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n, m, K, P;
long long ans, Max;
long long h[maxn], a[maxn];
inline int read() {
  int x = 0;
  bool fopt = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') fopt = 0;
  for (; isdigit(ch); ch = getchar()) x = (x << 3) + (x << 1) + ch - 48;
  return fopt ? x : -x;
}
inline void Clear(queue<pair<int, int> > &q) {
  queue<pair<int, int> > temp;
  swap(temp, q);
}
queue<pair<int, int> > q[maxn];
inline bool Judge(long long x) {
  for (int i = 1; i <= m; i++) Clear(q[i]);
  for (int i = 1; i <= n; i++) {
    long long now = x / a[i] + 1;
    if (now <= m) q[now].push(make_pair(i, 0));
  }
  for (int i = 1, cnt = 0; i <= m; i++, cnt += K) {
    while (!q[i].empty()) {
      if (cnt)
        cnt--;
      else
        return 0;
      pair<int, int> now = q[i].front();
      q[i].pop();
      now.second++;
      long long nxt = (x + now.second * P) / now.first + 1;
      if (nxt <= m) q[nxt].push(now);
    }
  }
  long long tot = 0;
  for (int i = 1; i <= n; i++)
    tot += (max(h[i] + a[i] * m - x, 0LL) + P - 1) / P;
  return tot <= m * K;
}
int main() {
  n = read();
  m = read();
  K = read();
  P = read();
  for (int i = 1; i <= n; i++) {
    h[i] = read();
    a[i] = read();
    Max = max(Max, h[i] + a[i] * m);
  }
  long long l = 0, r = Max;
  while (l <= r) {
    long long mid = (l + r) >> 1;
    if (Judge(mid)) {
      r = mid - 1;
      ans = mid;
    } else
      l = mid + 1;
  }
  printf("%lld\n", ans);
  return 0;
}
