#include <bits/stdc++.h>
using namespace std;
long long n, m, k, p, h[100005], a[100005], len[100005], cnt[100005], v[100005],
    c[5005];
bool Check(long long mid) {
  long long sum = 0;
  for (long long i = 1; i <= n; i++) {
    len[i] = h[i] + a[i] * m - mid;
    v[i] = -1;
    cnt[i] = 0;
    if (len[i] <= 0) continue;
    cnt[i] = (len[i] - 1) / p;
    v[i] = len[i] - cnt[i] * p;
    sum = sum + cnt[i] + 1;
  }
  if (sum > m * k) return 0;
  for (long long i = 1; i <= m; i++) c[i] = 0;
  for (long long i = 1; i <= n; i++) {
    long long H = h[i];
    for (long long j = 1; j <= m;) {
      while (H >= p && cnt[i]) H -= p, cnt[i]--, c[j]++;
      if (v[i] != -1 && H >= v[i]) H -= v[i], v[i] = -1, c[j]++;
      if (v[i] == -1 && !cnt[i]) break;
      long long tmp = ((v[i] == -1 ? p : v[i]) - H - 1) / a[i];
      H = H + a[i] * (tmp + 1);
      j = j + tmp + 1;
    }
  }
  for (long long i = m - 1; i >= 1; i--) c[i] += c[i + 1];
  for (long long i = m; i >= 1; i--)
    if (c[i] > k * (m - i + 1)) return 0;
  return 1;
}
int main() {
  scanf("%lld%lld%lld%lld", &n, &m, &k, &p);
  long long l = 0, r = 0, mid = 0, ans = 0;
  for (long long i = 1; i <= n; i++) {
    scanf("%lld%lld", &h[i], &a[i]);
    r = max(r, h[i] + a[i] * m);
    l = max(l, a[i]);
  }
  while (l <= r) {
    mid = (l + r) >> 1;
    if (Check(mid))
      ans = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  printf("%lld\n", ans);
  return 0;
}
