#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
inline void smax(A &a, const B &b) {
  if (b > a) a = b;
}
int n, m, k, p, mx;
int h[101010], a[101010];
set<pair<long long, int> > s;
long long H[101010];
inline bool can(long long first) {
  s.clear();
  long long cnt = 0;
  for (int i = 1; i <= n; i++) {
    long long tar = first - (long long)a[i] * m;
    if (tar < h[i]) {
      cnt += (h[i] - tar + p - 1) / p;
      if (cnt > mx) return false;
      H[i] = first, s.insert(pair<long long, int>(H[i] / a[i], i));
    }
  }
  if (!s.empty())
    for (int i = 1; i <= m; i++) {
      if (s.begin()->first < i) return false;
      for (int j = k; j--;) {
        int u = s.begin()->second;
        s.erase(s.begin());
        H[u] += p;
        s.insert(pair<long long, int>(H[u] / a[u], u));
      }
    }
  return true;
}
int main() {
  scanf("%d %d %d %d", &n, &m, &k, &p);
  long long st = 0, ed = 1;
  mx = m * k;
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", h + i, a + i);
    smax(st, a[i] - 1);
    smax(ed, h[i] + (long long)a[i] * m);
  }
  while (st + 1 < ed) {
    long long md = st + ed >> 1;
    if (can(md))
      ed = md;
    else
      st = md;
  }
  printf("%I64d", ed);
}
