#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  char i = getchar();
  long long f = 1, res = 0;
  while (i < '0' || i > '9') {
    if (i == '-') f = -1;
    i = getchar();
  }
  while (i >= '0' && i <= '9') {
    res = res * 10 + i - '0';
    i = getchar();
  }
  return res * f;
}
const int N = 1e5 + 50;
long long h[N], a[N], n, m, k, p;
struct bamboo {
  long long time, id;
  bool operator<(const bamboo& A) const { return time > A.time; }
  bamboo(long long T, long long ID) : time(T), id(ID) {}
};
priority_queue<bamboo> q;
long long cnt[N];
bool pd(long long mid) {
  while (!q.empty()) {
    q.pop();
  }
  memset(cnt, 0, sizeof(cnt));
  for (register int i = 1; i <= n; ++i) {
    if (mid - a[i] * m < h[i]) {
      q.push(bamboo(mid / a[i], i));
    }
  }
  for (register int i = 1; i <= m; ++i) {
    if (q.empty()) {
      break;
    }
    for (register int j = 1; j <= k; ++j) {
      if (q.empty()) {
        break;
      }
      bamboo now = q.top();
      q.pop();
      if (now.time < i) {
        return false;
      }
      cnt[now.id]++;
      if (mid + cnt[now.id] * p - a[now.id] * m < h[now.id]) {
        q.push(bamboo((mid + cnt[now.id] * p) / a[now.id], now.id));
      }
    }
  }
  return q.empty();
}
int main() {
  n = read();
  m = read();
  k = read();
  p = read();
  long long l = 0, r = -10, ans = -1, mid;
  for (register int i = 1; i <= n; ++i) {
    h[i] = read();
    a[i] = read();
    r = max(r, h[i] + a[i] * m);
  }
  while (l <= r) {
    mid = (l + r) >> 1;
    if (pd(mid)) {
      r = mid - 1;
      ans = mid;
    } else
      l = mid + 1;
  }
  printf("%lld", ans);
}
