#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e6 + 100;
const long long MAXK = 30;
long long n, m, k, p;
long long a[MAXN], h[MAXN], dp[MAXN], todo[MAXN];
long long calc(long long x, long long y) {
  return max(0LL, (y - h[x] + a[x] - 1) / a[x]);
}
bool check(long long H) {
  long long tof = 0;
  memset(todo, 0, sizeof todo);
  for (long long i = 0; i < n; i++) {
    if (a[i] > H) return false;
    dp[i] = max(0LL, h[i] + m * a[i] - H);
    tof += (dp[i] + p - 1) / p;
  }
  if (tof > m * k) return false;
  for (long long i = 0; i < n; i++)
    while (dp[i]) {
      todo[calc(i, dp[i])]++;
      dp[i] = max(0LL, dp[i] - p);
    }
  for (long long i = 0; i < m - 1; i++) todo[i + 1] += max(0LL, todo[i] - k);
  return (!(todo[m - 1] > k));
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> k >> p;
  for (long long i = 0; i < n; i++) cin >> h[i] >> a[i];
  long long l = -1, r = 1e18;
  while (r - l > 1) {
    long long mid = (r + l) / 2;
    (check(mid) ? r : l) = mid;
  }
  cout << r << '\n';
}
