#include <bits/stdc++.h>
int n, m, k, p;
long long int a[100003], b[100003];
int arr[5003];
int main() {
  scanf("%d%d%d%d", &n, &m, &k, &p);
  long long int max = 1000000000LL * 10000;
  for (int i = 0; i < n; ++i) {
    scanf("%lld%lld", &a[i], &b[i]);
  }
  long long int min = 0;
  while (max - min > 1) {
    for (int j = 0; j < m; ++j) arr[j] = 0;
    long long int mid = (min + max) >> 1;
    long long int cnt = 0;
    bool ok = true;
    for (int i = 0; i < n; ++i) {
      long long int rem = a[i] + b[i] * m - mid;
      if (rem <= 0) continue;
      long long int curc = (rem - 1) / p + 1;
      cnt += curc;
      if (cnt > m * k) {
        ok = false;
        break;
      }
      for (int j = 0; j < curc; ++j) {
        long long int d = rem - (curc - 1 - j) * p;
        int k;
        if (d <= a[i]) {
          k = 0;
        } else {
          k = (d - a[i] - 1) / b[i] + 1;
        }
        if (k >= m) {
          ok = false;
          break;
        }
        ++arr[k];
      }
    }
    if (ok) {
      int left = 0;
      for (int j = 0; j < m; ++j) {
        left += arr[j];
        if (left < k)
          left = 0;
        else
          left -= k;
      }
      if (left > 0) ok = false;
    }
    if (ok) {
      max = mid;
    } else {
      min = mid;
    }
  }
  printf("%lld\n", max);
}
