#include <bits/stdc++.h>
const int N = 100000;
int n, m, k;
long long a[N + 5], h[N + 5], p;
std::queue<std::pair<int, int> > que[N + 5];
bool check(long long x) {
  for (int i = 1; i <= m; i++) {
    while (!que[i].empty()) que[i].pop();
  }
  for (int i = 1; i <= n; i++) {
    long long s = x / a[i] + 1;
    if (s <= m) que[s].push(std::make_pair(i, 0));
  }
  for (int i = 1, c = 0; i <= m; i++, c += k) {
    while (!que[i].empty()) {
      if (c)
        c--;
      else
        return false;
      std::pair<int, int> f = que[i].front();
      que[i].pop();
      f.second++;
      long long s = (f.second * p + x) / a[f.first] + 1;
      if (s <= m) que[s].push(f);
    }
  }
  long long s = 0;
  for (int i = 1; i <= n; i++)
    s += (std::max(a[i] * m + h[i] - x, 0LL) + p - 1) / p;
  return s <= m * k;
}
int main() {
  scanf("%d%d%d%lld", &n, &m, &k, &p);
  for (int i = 1; i <= n; i++) scanf("%lld%lld", &h[i], &a[i]);
  long long le = 0, ri = 0;
  for (int i = 1; i <= n; i++) ri = std::max(ri, h[i] + m * a[i]);
  while (le < ri) {
    long long mid = (le + ri) >> 1;
    if (check(mid))
      ri = mid;
    else
      le = mid + 1;
  }
  printf("%lld\n", ri);
}
