#include <bits/stdc++.h>
const int MAXN = 1e5 + 10;
const int INF = 1e9 + 10;
using namespace std;
int N, M, K, P;
long long a[MAXN], b[MAXN];
long long h[MAXN], d[MAXN];
long long ceil(long long num, long long den) { return (num / den) + 1LL; }
bool check(long long x) {
  ("\nChecking %lld\n", x);
  priority_queue<pair<long long, int>, vector<pair<long long, int> >,
                 greater<pair<long long, int> > >
      fila;
  for (int i = 1; i <= N; i++) {
    if (x - a[i] < 0) return false;
    h[i] = x;
    d[i] = ceil(h[i] - a[i], a[i]);
    if (x - a[i] * M < b[i]) fila.push(make_pair(d[i], i));
  }
  int charge = 0;
  for (int i = 1; i <= M; i++, charge++) {
    ("Processing day %d\n", i);
    for (int j = 1; j <= K; j++) {
      if (fila.empty()) return true;
      pair<long long, int> topo = fila.top();
      fila.pop();
      ("My top is %lld %d e coloquei \n", topo.first - charge, topo.second);
      if (topo.first - charge <= 0) return false;
      h[topo.second] += P;
      d[topo.second] =
          ceil(h[topo.second] - a[topo.second] * i, a[topo.second]) + charge;
      if (h[topo.second] - a[topo.second] * M < b[topo.second])
        fila.push(make_pair(d[topo.second], topo.second));
      ("%lld\n", d[topo.second]);
    }
  }
  return fila.empty();
}
int main() {
  scanf("%d%d%d%d", &N, &M, &K, &P);
  for (int i = 1; i <= N; i++) scanf("%lld%lld", &b[i], &a[i]);
  long long l = 0, r = 1e13 + 10, mid, best;
  while (l <= r) {
    mid = (l + r) >> 1;
    if (check(mid)) {
      best = mid;
      r = mid - 1;
    } else
      l = mid + 1;
  }
  printf("%lld\n", best);
}
