#include <bits/stdc++.h>
using namespace std;
int n, m, K;
long long int P, h[110000], a[110000];
long long int nowh[110000];
priority_queue<pair<int, int>, vector<pair<int, int> >,
               greater<pair<int, int> > >
    heap;
bool check(long long int lastMaxH) {
  while (!heap.empty()) heap.pop();
  for (int i = 1; i <= n; i++) nowh[i] = lastMaxH;
  for (int i = 1; i <= n; i++) {
    if (nowh[i] - m * a[i] >= 0) continue;
    heap.push(make_pair(nowh[i] / a[i] - 1, i));
  }
  int tot = 0;
  for (tot = 0; tot <= m * K; tot++) {
    if (heap.empty()) break;
    pair<int, int> now = heap.top();
    heap.pop();
    if (now.first < tot / K) return false;
    nowh[now.second] += P;
    if (nowh[now.second] - m * a[now.second] >= 0) continue;
    heap.push(make_pair(nowh[now.second] / a[now.second] - 1, now.second));
  }
  if (tot > m * K) return false;
  for (int i = 1; i <= n; i++) {
    if (nowh[i] - m * a[i] >= h[i]) continue;
    tot += ((h[i] - nowh[i] + m * a[i]) + P - 1) / P;
    if (tot > m * K) return false;
  }
  return true;
}
int main() {
  scanf("%d%d%d%I64d", &n, &m, &K, &P);
  for (int i = 1; i <= n; i++) scanf("%I64d%I64d", &h[i], &a[i]);
  long long int lowerBound = 0, upperBound = 1e15, ans = -1;
  while (lowerBound <= upperBound) {
    long long int mid = (lowerBound + upperBound) >> 1;
    if (check(mid)) {
      ans = mid;
      upperBound = mid - 1;
    } else
      lowerBound = mid + 1;
  }
  printf("%I64d\n", ans);
  return 0;
}
