#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long w = 0, x = 0;
  char c = getchar();
  while (!isdigit(c)) w |= c == '-', c = getchar();
  while (isdigit(c)) x = x * 10 + (c ^ 48), c = getchar();
  return w ? -x : x;
}
namespace star {
const long long maxn = 1e5 + 10;
long long n, m, k, p;
long long h[maxn], a[maxn], cnt[maxn];
inline bool check(long long x) {
  memset(cnt, 0, sizeof cnt);
  priority_queue<pair<long long, long long>,
                 vector<pair<long long, long long> >,
                 greater<pair<long long, long long> > >
      q;
  for (long long i = 1; i <= n; i++)
    if (x - a[i] * m < h[i]) q.push(make_pair(x / a[i], i));
  for (long long i = 1; !q.empty() and i <= m; i++)
    for (long long j = 1; !q.empty() and j <= k; j++) {
      pair<long long, long long> now = q.top();
      q.pop();
      if (now.first < i) return false;
      ++cnt[now.second];
      if (x + cnt[now.second] * p - a[now.second] * m < h[now.second])
        q.push(
            make_pair((x + cnt[now.second] * p) / a[now.second], now.second));
    }
  return q.empty();
}
inline void work() {
  n = read(), m = read(), k = read(), p = read();
  long long l = 0, r = 0, mid;
  for (long long i = 1; i <= n; i++)
    h[i] = read(), a[i] = read(), r = max(r, h[i] + 1ll * a[i] * m);
  long long ans = r;
  while (l <= r) check(mid = l + r >> 1) ? ans = mid, r = mid - 1 : l = mid + 1;
  printf("%lld\n", ans);
}
}  // namespace star
signed main() {
  star::work();
  return 0;
}
