#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n, m, k, p;
long long a[maxn], h[maxn], height[maxn];
bool check(long long H) {
  fill(height + 1, height + n + 1, H);
  priority_queue<pair<long long, int>, vector<pair<long long, int> >,
                 greater<pair<long long, int> > >
      que;
  for (int i = 1; i <= n; i++)
    if (H - a[i] * m < h[i]) que.push({H / a[i], i});
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= k; j++) {
      if (que.empty()) return true;
      auto now = que.top();
      que.pop();
      if (now.first < i) return false;
      height[now.second] += p;
      now.first = height[now.second] / a[now.second];
      if (height[now.second] - a[now.second] * m < h[now.second]) que.push(now);
    }
  }
  return que.empty();
}
int main() {
  scanf("%d%d%d%d", &n, &m, &k, &p);
  for (int i = 1; i <= n; i++) scanf("%lld%lld", &h[i], &a[i]);
  long long l = 0, r = 1e18, res = 0;
  while (l <= r) {
    long long mid = l + r >> 1;
    if (check(mid))
      res = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  printf("%lld\n", res);
  return 0;
}
