#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
struct node {
  long long day;
  int id;
  bool operator<(const node& a) const { return day > a.day; }
};
long long a[N], h[N], t[N];
long long n, m, k, p;
bool check(long long x) {
  priority_queue<node> q;
  for (int i = 1; i <= n; i++) {
    t[i] = x;
    if (x - a[i] * m < h[i]) q.push({x / a[i], i});
  }
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= k; j++) {
      if (q.empty()) return true;
      int day = q.top().day, id = q.top().id;
      q.pop();
      if (day < i) return false;
      t[id] += p;
      if (t[id] - a[id] * m < h[id]) q.push({t[id] / a[id], id});
    }
  return q.empty();
}
int main() {
  scanf("%lld%lld%lld%lld", &n, &m, &k, &p);
  for (int i = 1; i <= n; i++) scanf("%lld%lld", &h[i], &a[i]);
  long long l = 0, r = 1ll << 50;
  while (l < r) {
    long long mid = (l + r) >> 1;
    if (check(mid))
      r = mid;
    else
      l = mid + 1;
  }
  printf("%lld\n", l);
  return 0;
}
