#include <bits/stdc++.h>
using namespace std;
bool debug = 1;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
long long ln, lk, lm;
int h[100005], p, a[100005], cnt[100005];
long long day(long long val, long long ai) {
  long long ans = val / ai;
  return ans;
}
bool ck(long long x) {
  priority_queue<pair<int, int>, std::vector<pair<int, int>>,
                 std::greater<pair<int, int>>>
      q;
  memset(cnt, 0, sizeof cnt);
  for (int(i) = 0; (i) < (int)(n); (i)++)
    if (x - (long long)a[i] * m < h[i]) {
      q.push({day(x, a[i]), i});
    }
  for (int(i) = 1; (i) <= (int)(m); (i)++) {
    for (int(j) = 1; (j) <= (int)(k); (j)++) {
      if (q.empty()) return 1;
      auto z = q.top();
      q.pop();
      if (z.first < i) return 0;
      int id = z.second;
      cnt[id]++;
      if (x + (long long)p * cnt[id] - (long long)a[id] * m < h[id]) {
        q.push({day(x + (long long)p * cnt[id], a[id]), id});
      }
    }
  }
  return q.empty();
}
int main() {
  scanf("%d%d%d%d", &n, &m, &k, &p);
  for (int(i) = 0; (i) < (int)(n); (i)++) scanf("%d%d", h + i, a + i);
  long long l = 0, r = 1e15;
  while (l + 1 < r) {
    long long mid = (l + r) / 2;
    if (ck(mid))
      r = mid;
    else
      l = mid + 1;
  }
  printf("%lld\n", ck(l) ? l : r);
  return 0;
}
