#include <bits/stdc++.h>
using namespace std;
const long long _ = 1e6 + 1;
long long n, m, k, p;
long long H[_], A[_];
long long height[_];
inline long long read() {
  long long x = 0;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return x;
}
bool check(long long MaxH) {
  fill(height + 1, height + 1 + n, MaxH);
  priority_queue<pair<long long, long long>,
                 vector<pair<long long, long long> >,
                 greater<pair<long long, long long> > >
      Q;
  while (!Q.empty()) Q.pop();
  for (long long i = 1; i <= n; i++)
    if (MaxH - m * A[i] < H[i]) Q.push(make_pair(MaxH / A[i], i));
  for (long long i = 1; i <= m; i++) {
    for (long long j = 1; j <= k; j++) {
      if (Q.empty()) return true;
      pair<long long, long long> now = Q.top();
      Q.pop();
      if (now.first < i) return false;
      height[now.second] += p;
      now.first = height[now.second] / A[now.second];
      if (height[now.second] - m * A[now.second] < H[now.second]) Q.push(now);
    }
  }
  return Q.empty();
}
signed main() {
  n = read(), m = read(), k = read(), p = read();
  for (long long i = 1; i <= n; i++) H[i] = read(), A[i] = read();
  long long L = 0, ans = 0, R = 1LL << 60;
  for (long long i = 1; i <= n; i++) L = min(L, A[i]);
  while (L <= R) {
    long long mid = (L + R) >> 1;
    if (check(mid))
      ans = mid, R = mid - 1;
    else
      L = mid + 1;
  }
  printf("%lld\n", ans);
  return 0;
}
