#include <bits/stdc++.h>
using namespace std;
const int MAX = 100005;
long long n, m, k, p;
long long h[MAX], a[MAX], x[MAX];
priority_queue<pair<long long, int>, vector<pair<long long, int> >,
               greater<pair<long long, int> > >
    s;
bool can(long long st) {
  while (!s.empty()) s.pop();
  for (int i = 0; i < n; i++) {
    x[i] = st;
    s.push(make_pair(x[i] / a[i], i));
  }
  long long cnt = 0;
  for (int i = 1; i <= m; i++) {
    int id = s.top().second;
    if (x[id] - i * a[id] < 0) return false;
    for (int j = 0; j < k; j++) {
      int id = s.top().second;
      if (x[id] - m * a[id] < 0) {
        s.pop();
        x[id] += p;
        s.push(make_pair(x[id] / a[id], id));
        cnt++;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    x[i] -= m * a[i];
    if (x[i] < 0) return false;
    if (x[i] < h[i]) cnt += (h[i] - x[i] + p - 1) / p;
  }
  return (cnt <= k * m);
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m >> k >> p;
  for (int i = 0; i < n; i++) cin >> h[i] >> a[i];
  long long l = -1, r = 1e15;
  while (r - l > 1) {
    long long mid = (l + r) / 2;
    if (can(mid))
      r = mid;
    else
      l = mid;
  }
  cout << r << endl;
  return 0;
}
