#include <bits/stdc++.h>
template <typename T>
inline void read(T &x) {
  x = 0;
  char c = getchar();
  while (!isdigit(c)) c = getchar();
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
}
using namespace std;
const long long inf = 1e16;
inline void MIN(long long &a, long long b) {
  if (b < a) a = b;
}
inline void MAX(long long &a, long long b) {
  if (b > a) a = b;
}
int n, m, k, p;
int h[101000], a[101000];
long long nw[101000];
priority_queue<pair<long long, long long> > q;
inline bool che(long long H) {
  while (!q.empty()) q.pop();
  for (int i = 1; i <= n; ++i) nw[i] = H;
  for (int i = 1; i <= n; ++i)
    if (H - 1ll * m * a[i] < h[i]) q.push(make_pair(-(H / a[i]), i));
  for (int i = 1; i <= m; ++i) {
    for (int j = 1; j <= k; ++j) {
      if (q.empty()) return true;
      pair<long long, long long> pr = q.top();
      q.pop();
      if (-pr.first < i) return false;
      int id = pr.second;
      nw[id] += p;
      if (nw[id] - 1ll * m * a[id] < h[id])
        q.push(make_pair(-(nw[id] / a[id]), id));
    }
  }
  return q.empty();
}
int main() {
  read(n), read(m), read(k), read(p);
  long long l = 0, r = 0, res = 0;
  for (int i = 1; i <= n; ++i)
    read(h[i]), read(a[i]), MAX(r, h[i] + 1ll * a[i] * m), MAX(l, a[i]);
  while (l <= r) {
    long long mid = (l + r) >> 1;
    if (che(mid))
      res = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  printf("%lld\n", res);
  return 0;
}
