#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 2;
int n, m, k, p;
long long a[N], h[N];
struct TState {
  int day;
  long long cur_h, end_h, a;
};
inline bool operator<(TState lhs, TState rhs) { return lhs.day < rhs.day; }
bool Check(long long max_h) {
  priority_queue<TState> pq;
  for (int i = 0; i < n; ++i)
    if (max_h / a[i] < m)
      pq.push({m - int(max_h / a[i]), max_h % a[i], h[i], a[i]});
    else if (max_h - a[i] * m < h[i])
      pq.push({0, max_h - a[i] * m, h[i], a[i]});
  for (int i = m; i >= 1; --i)
    for (int j = k; j > 0 && !pq.empty(); --j) {
      TState top = pq.top();
      pq.pop();
      if (top.day >= i) return false;
      top.cur_h += p;
      if (top.day > 0) {
        long long days = min(top.cur_h / top.a, (long long)top.day);
        top.day -= days;
        top.cur_h -= days * top.a;
        if (top.day > 0 || (top.day == 0 && top.cur_h < top.end_h))
          pq.push(top);
      } else if (top.cur_h < top.end_h)
        pq.push(top);
    }
  return pq.empty();
}
int main() {
  cin >> n >> m >> k >> p;
  for (int i = 0; i < n; ++i) cin >> h[i] >> a[i];
  long long lo = *max_element(a, a + n), hi = 1e13, res = -1;
  while (lo <= hi) {
    long long mid = (lo + hi) / 2;
    if (Check(mid))
      res = mid, hi = mid - 1;
    else
      lo = mid + 1;
  }
  cout << res;
  return 0;
}
