#include <bits/stdc++.h>
using namespace std;
long long n, m, k, p, h[100100], a[100100], l[100100], b[100100], L, R, ans;
bool check(long long limit) {
  long long sum = 0;
  for (long long i = 1; i <= n; i++)
    if (l[i] > limit) sum += (l[i] - limit - 1) / p + 1;
  if (sum > m * k) return false;
  memset(b, 0, sizeof(b));
  for (long long i = 1; i <= n; i++) {
    if (l[i] <= limit) continue;
    for (long long j = (l[i] - limit - 1) % p - h[i] + a[i];
         j <= l[i] - limit - h[i] + a[i] - 1; j += p)
      b[max(0ll, j / a[i])]++;
  }
  long long now = 0;
  for (long long i = 0; i < m; i++) now = max(0ll, now - k + b[i]);
  return now == 0;
}
signed main() {
  scanf("%lld%lld%lld%lld", &n, &m, &k, &p);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld%lld", &h[i], &a[i]);
    l[i] = h[i] + m * a[i];
    L = max(L, a[i]);
    R = max(R, l[i]);
  }
  while (L <= R) {
    long long mid = (L + R) / 2;
    if (check(mid))
      ans = mid, R = mid - 1;
    else
      L = mid + 1;
  }
  printf("%lld\n", ans);
}
