#include <bits/stdc++.h>
using namespace std;
long long n, m, k, p;
long long h[100005];
long long a[100005];
long long H[100005];
long long day;
struct cmp {
  bool operator()(int A, int B) {
    return ((H[A] - (m - day) * a[A]) / (a[A])) >=
           ((H[B] - (m - day) * a[B]) / (a[B]));
  };
};
bool check(long long mid) {
  for (int i = 1; i <= n; i++) H[i] = mid;
  day = m;
  priority_queue<int, vector<int>, cmp> Q;
  for (int i = 1; i <= n; i++) {
    if (H[i] - m * a[i] < h[i]) Q.push(i);
  }
  for (day = m; day > 0 && !Q.empty(); day--) {
    for (int i = 0; i < k && !Q.empty(); i++) {
      int cur = Q.top();
      Q.pop();
      if (H[cur] - (m - day + 1) * a[cur] < 0) {
        return false;
      }
      H[cur] += p;
      if (H[cur] - m * a[cur] < h[cur]) Q.push(cur);
    }
  }
  for (int i = 1; i <= n; i++) {
    if (H[i] - m * a[i] < h[i]) {
      return false;
    }
  }
  return true;
}
int main() {
  scanf("%lld %lld %lld %lld", &n, &m, &k, &p);
  long long s = 123456789123ll;
  long long t = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%lld %lld", &h[i], &a[i]);
    t = max(a[i] * m + h[i], t);
    s = min(s, a[i]);
  }
  while (s <= t) {
    long long mid = (s + t) / 2ll;
    if (check(mid)) {
      t = mid - 1;
    } else {
      s = mid + 1;
    }
  }
  printf("%lld\n", s);
}
