#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
long long n, m, k, h[MAXN], aa[MAXN], rh[MAXN], p;
priority_queue<pair<long long, long long> > q;
bool chk(long long x) {
  while (!q.empty()) {
    q.pop();
  }
  for (int i = 1; i <= n; i++) {
    rh[i] = x;
    if (x - m * aa[i] < h[i]) {
      q.push(make_pair(-(x / aa[i]), i));
    }
  }
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= k; j++) {
      if (q.empty()) {
        return 1;
      }
      pair<long long, long long> a = q.top();
      q.pop();
      if (-a.first < i) {
        return 0;
      }
      rh[a.second] += p;
      if (rh[a.second] - m * aa[a.second] < h[a.second]) {
        q.push(make_pair(-(rh[a.second] / aa[a.second]), a.second));
      }
    }
  }
  return q.empty();
}
int main() {
  scanf("%lld%lld%lld%lld", &n, &m, &k, &p);
  for (int i = 1; i <= n; i++) {
    scanf("%lld%lld", &h[i], &aa[i]);
  }
  long long l = 0, r = 1e18;
  while (l < r) {
    long long mid = (l + r) >> 1;
    if (chk(mid)) {
      r = mid;
    } else {
      l = mid + 1;
    }
  }
  printf("%lld\n", l);
  return 0;
}
