#include <bits/stdc++.h>
int n, m, k, p;
long long H[100100], A[100100], L[100100], t[100100];
long long max(long long a, long long b) { return (a > b) ? a : b; }
int max(int a, int b) { return (a > b) ? a : b; }
int Check(long long h) {
  int temp = 0;
  long long tot = 0;
  for (int i = 1; i <= n; i++) tot += max(0LL, (L[i] - h + p - 1) / p);
  if (tot > m * k) return 0;
  for (int i = 0; i < m; i++) t[i] = 0;
  for (int i = 1; i <= n; i++)
    if (L[i] > h) {
      for (long long j = (L[i] - h) % p == 0 ? p : (L[i] - h) % p;
           j <= L[i] - h; j += p) {
        if (j - H[i] <= 0)
          t[0]++;
        else if (j - H[i] > A[i] * (m - 1))
          return 0;
        else
          t[(j - H[i] + A[i] - 1) / A[i]]++;
      }
    }
  for (int i = 0; i < m; i++) {
    temp += t[i];
    temp = max(0, temp - k);
  }
  return (temp == 0);
}
void Find() {
  long long l = 0, r = 2e13, mid;
  while (l + 1 < r) {
    mid = (l + r) >> 1;
    if (Check(mid))
      r = mid;
    else
      l = mid;
  }
  printf("%I64d\n", r);
}
int main() {
  scanf("%d%d%d%d", &n, &m, &k, &p);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", H + i, A + i);
    L[i] = H[i] + A[i] * m;
  }
  Find();
  return 0;
}
