#include <bits/stdc++.h>
using namespace std;
int n, m, k;
long long p, l, r, a[100010], h[100010], st[100010], mid;
bool jd(long long x) {
  int i;
  long long sum = 0;
  for (i = 1; i <= n; i++) {
    if (x < a[i]) return 0;
    sum += max(0LL, (st[i] - x + p - 1) / p);
  }
  if (sum > m * k) return 0;
  int c[5010] = {};
  for (i = 1; i <= n; i++)
    if (st[i] > x) {
      sum = (st[i] - x - 1) % p + 1;
      while (sum <= st[i] - x) {
        c[max(0LL, (sum - h[i] + a[i] - 1) / a[i])]++;
        sum += p;
      }
    }
  sum = 0;
  for (i = 0; i < m; i++) sum = max(0LL, sum + c[i] - k);
  return sum == 0LL;
}
int main() {
  scanf("%d%d%d%I64d", &n, &m, &k, &p);
  for (int i = 1; i <= n; i++) {
    scanf("%I64d%I64d", &h[i], &a[i]);
    st[i] = a[i] * m + h[i];
  }
  l = 0;
  r = 200000000000000;
  ;
  while (l < r) {
    mid = (l + r) / 2;
    if (jd(mid))
      r = mid;
    else
      l = mid + 1;
  }
  printf("%I64d", l);
}
