#include <bits/stdc++.h>
using namespace std;
int read() {
  char ch;
  for (ch = getchar(); ch < '0' || ch > '9'; ch = getchar())
    ;
  int x = ch - '0';
  for (ch = getchar(); ch >= '0' && ch <= '9'; ch = getchar())
    x = x * 10 + ch - '0';
  return x;
}
const int N = 1e5 + 5;
int n, m, k, p, cnt[N];
long long l[N], h[N], a[N];
bool check(long long x) {
  long long tot = 0;
  for (int i = 1; i <= n; i++)
    l[i] = h[i] + a[i] * m, tot += max(0ll, (l[i] - x + p - 1) / p);
  if (tot > m * k) return 0;
  for (int i = 0; i <= m; i++) cnt[i] = 0;
  for (int i = 1; i <= n; i++)
    if (l[i] > x)
      for (long long tmp = (l[i] - x - 1) % p + 1; tmp <= l[i] - x; tmp += p)
        if (tmp <= h[i])
          cnt[0]++;
        else if (tmp > h[i] + a[i] * (m - 1))
          return 0;
        else
          cnt[(tmp - h[i] + a[i] - 1) / a[i]]++;
  int ret = 0;
  for (int i = 0; i <= m - 1; i++) {
    ret += cnt[i];
    ret = max(0, ret - k);
  }
  return !ret;
}
int main() {
  n = read();
  m = read();
  k = read();
  p = read();
  for (int i = 1; i <= n; i++) h[i] = read(), a[i] = read();
  long long l = 0, r = 1e15, ans = 0;
  while (l <= r) {
    long long mid = l + r >> 1;
    if (check(mid))
      ans = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  printf("%lld\n", ans);
  return 0;
}
