#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
int n, m, q;
long long p;
pair<long long, long long> a[200000];
long long t[200000];
long long dat[200000];
long long ceil(long long x, long long y) { return (x + y - 1) / y; }
int param(long long x) {
  int i, j, k;
  long long sum = 0;
  for (i = 0; i < n; i++)
    t[i] = max(0ll, ceil(a[i].first + a[i].second * m - x, p)), sum += t[i];
  if (sum > m * q) return 0;
  fill(dat, dat + m, 0);
  for (i = 0; i < n; i++) {
    if (a[i].first + a[i].second * m - x < 0) continue;
    long long Q = (a[i].first + a[i].second * m - x) / p,
              R = (a[i].first + a[i].second * m - x) % p;
    long long now = R == 0 ? p : R;
    for (j = 0; j <= Q - (R == 0); j++) {
      long long day = max(0ll, ceil(now - a[i].first, a[i].second));
      now += p;
      if (day >= m) return 0;
      dat[day]++;
    }
  }
  long long now = 0;
  for (i = 0; i < m; i++) {
    now += dat[i];
    now -= min((long long)q, now);
  }
  if (now == 0) return 1;
  return 0;
}
int main() {
  int i, j, k;
  scanf("%d%d%d%I64d", &n, &m, &q, &p);
  for (i = 0; i < n; i++) scanf("%I64d%I64d", &a[i].first, &a[i].second);
  long long low = 0, high = 1e14, mid;
  while (low <= high) {
    mid = (low + high) / 2;
    if (param(mid))
      high = mid - 1;
    else
      low = mid + 1;
  }
  printf("%I64d", low);
  return 0;
}
