#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  char ch = getchar();
  long long res = 0, f = 1;
  for (; ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') f = -1;
  for (; ch >= '0' && ch <= '9'; ch = getchar())
    res = (res << 3) + (res << 1) + (ch - '0');
  return res * f;
}
const long long MAXN = 1e5 + 5, inf = 1e18;
long long n, h[MAXN], a[MAXN], ans, m, k, p;
long long alf[MAXN];
inline bool check(long long maxx) {
  priority_queue<pair<long long, long long> > q;
  for (long long i = 1; i <= n; ++i) {
    alf[i] = maxx;
    if (alf[i] - a[i] * m < h[i]) q.push(make_pair(-(alf[i] / a[i]), i));
  }
  for (long long dat = 1; dat <= m; ++dat) {
    for (long long i = 1; i <= k; ++i) {
      if (q.empty()) return 1;
      long long di = -q.top().first, id = q.top().second;
      q.pop();
      if (di < dat) return 0;
      alf[id] += p;
      if (alf[id] - a[id] * m < h[id])
        q.push(make_pair(-(alf[id] / a[id]), id));
    }
  }
  return q.empty();
}
signed main() {
  n = read(), m = read(), k = read(), p = read();
  for (long long i = 1; i <= n; ++i) h[i] = read(), a[i] = read();
  long long l = 0, r = inf;
  while (l <= r) {
    long long mid = (l + r) >> 1;
    if (check(mid))
      ans = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  cout << ans << endl;
  return 0;
}
