#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T, class U>
void chmin(T& t, const U& u) {
  if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
  if (t < u) t = u;
}
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  os << "{";
  for (int i = 0; i < (v.size()); i++) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}
const ll INF = TEN(16);
using pll = pair<ll, ll>;
using p3 = pair<pll, int>;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m, k, p;
  cin >> n >> m >> k >> p;
  V<ll> h(n), a(n);
  for (int i = 0; i < (n); i++) cin >> h[i] >> a[i];
  auto ok = [&](ll x) {
    V<int> la(n, -1);
    V<ll> cur(n, x);
    (void(0));
    priority_queue<pll, V<pll>, greater<pll>> que;
    priority_queue<pll> need;
    for (int i = 0; i < (n); i++) {
      ll md = x / a[i] + 1;
      if (md <= m) {
        que.emplace(md, i);
      } else if (x - m * a[i] < h[i]) {
        need.emplace(h[i] - (x - m * a[i]), i);
      }
    }
    for (int i = 0; i < (m); i++) {
      int rem = k;
      while (rem > 0 && que.size()) {
        auto pr = que.top();
        que.pop();
        if (pr.first - 1 <= i) return false;
        int id = pr.second;
        ll v = cur[id] + p - (i - la[id]) * a[id];
        rem--;
        la[id] = i;
        cur[id] = v;
        if (v < 0) return false;
        ll md = i + 1 + v / a[id] + 1;
        (void(0));
        if (md <= m)
          que.emplace(md, id);
        else {
          ll sh = h[id] - (v - (m - i - 1) * a[id]);
          if (sh > 0) need.emplace(sh, id);
        }
      }
      while (rem > 0 && need.size()) {
        auto pr = need.top();
        need.pop();
        int id = pr.second;
        rem--;
        if (pr.first - p > 0) {
          need.emplace(pr.first - p, id);
        }
      }
    }
    return que.size() == 0 && need.size() == 0;
  };
  ll lo = 0, hi = INF;
  while (hi - lo > 1) {
    ll m = (lo + hi) / 2;
    if (ok(m)) {
      hi = m;
    } else {
      lo = m;
    }
  }
  cout << hi << endl;
  return 0;
}
