#include <bits/stdc++.h>
using namespace std;
template <typename tn>
void read(tn &a) {
  tn x = 0, f = 1;
  char c = ' ';
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  a = x * f;
}
int n, m, k, p;
long long a[101000], h[101000];
struct node {
  long long H, a, h;
};
bool operator>(node a, node b) { return 1.l * a.H / a.a > 1.l * b.H / b.a; }
bool check(long long lim) {
  priority_queue<node, vector<node>, greater<node> > q;
  for (int i = 1; i <= n; i++) q.push({lim, a[i], h[i]});
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= k; j++) {
      while (!q.empty()) {
        auto u = q.top();
        q.pop();
        if (1.l * (u.H + 1) / u.a <= i) return 0;
        if (1.l * (u.H - u.h) / u.a >= m) continue;
        u.H += p;
        q.push(u);
        break;
      }
      if (q.empty()) return 1;
    }
  }
  while (!q.empty()) {
    auto u = q.top();
    q.pop();
    if (1.l * (u.H - u.h) / u.a < m) return 0;
  }
  return 1;
}
int main() {
  read(n);
  read(m);
  read(k);
  read(p);
  for (int i = 1; i <= n; i++) {
    read(h[i]);
    read(a[i]);
  }
  long long l = -1, r = 1e15;
  while (l + 1 < r) {
    long long mid = l + r >> 1;
    if (check(mid))
      r = mid;
    else
      l = mid;
  }
  cout << r << '\n';
  return 0;
}
