#include <bits/stdc++.h>
using namespace std;
const long double pi = 3.14159265359;
template <typename T>
T abs(T x) {
  return x > 0 ? x : -x;
}
template <typename T>
T sqr(T x) {
  return x * x;
}
const int maxn = 100005;
long long a[maxn], h[maxn];
long long n, m, k, p;
bool check(long long x) {
  priority_queue<pair<long long, int> > q;
  vector<long long> add(n, 0);
  for (int i = 0; i < n; i++) {
    long long need = x / a[i] + 1;
    q.push(make_pair(m - need + 1, i));
  }
  int _left = 0;
  for (int i = m; i >= 1; i--) {
    if (q.top().first == i) return false;
    for (int j = 0; j < k; j++) {
      auto v = q.top();
      q.pop();
      if (v.first < 1) {
        _left++;
        q.push(v);
        continue;
      }
      add[v.second] += p;
      long long need = (x + add[v.second]) / a[v.second] + 1;
      q.push(make_pair(m - need + 1, v.second));
    }
  }
  for (int i = 0; i < n; i++) {
    while (_left && x + add[i] - m * a[i] < h[i]) _left--, add[i] += p;
    if (x + add[i] - m * a[i] < h[i]) return false;
  }
  return true;
}
int main() {
  scanf("%lld %lld %lld %lld", &n, &m, &k, &p);
  for (int i = 0; i < n; i++) scanf("%lld %lld", h + i, a + i);
  long long lo = -1, hi = 1e16;
  while (hi - lo > 1) {
    long long mid = (lo + hi) >> 1;
    if (check(mid))
      hi = mid;
    else
      lo = mid;
  }
  cout << hi << endl;
  return 0;
}
