#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
const int N = 1e5 + 1000;
int n, m, k, c[N];
long long h[N], a[N], p, l, r, mid;
int check() {
  priority_queue<pair<long long, long long> > q;
  for (int i = 1; i <= n; i++) {
    if (h[i] + m * a[i] <= mid) continue;
    q.push(make_pair(-(mid / a[i]), i));
    c[i] = 0;
  }
  int cnt = 0;
  for (int i = 1; q.size() && i <= m; i++)
    for (int j = 1; q.size() && j <= k; j++) {
      if (-q.top().first < i) return 0;
      int x = q.top().second;
      q.pop();
      long long w = (mid + (++c[x]) * p) / a[x];
      if (w < m) q.push(make_pair(-w, x));
      ++cnt;
    }
  for (int i = 1; i <= n; i++) {
    long long w = mid + c[i] * p - m * a[i];
    if (h[i] <= w) continue;
    w = (h[i] - w - 1) / p + 1;
    if (cnt + w > m * k) return 0;
    cnt += w;
  }
  return 1;
}
int main() {
  n = read();
  m = read();
  k = read();
  p = read();
  for (int i = 1; i <= n; i++) {
    h[i] = read();
    a[i] = read();
    l = max(l, a[i]);
    r = max(r, h[i] + m * a[i]);
  }
  while (l < r) {
    mid = (l + r) >> 1;
    if (check())
      r = mid;
    else
      l = mid + 1;
  }
  cout << l << "\n";
  return 0;
}
