#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x) {
  x = 0;
  bool f = 0;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = 1;
  for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
  if (f) x = -x;
}
template <typename T>
void write(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) write(x / 10);
  putchar('0' + x % 10);
}
const int N = 200500;
priority_queue<pair<long long, long long> > q;
long long n, m, k, p;
long long w[N], h[N], a[N];
bool check(long long H) {
  while (q.size()) q.pop();
  for (int i = 1; i <= n; i++)
    if (H - a[i] * m < h[i]) q.push(make_pair(-H / a[i], i)), w[i] = H;
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= k; j++) {
      if (q.empty()) return true;
      pair<long long, long long> t = q.top();
      q.pop();
      if (-t.first < i) return false;
      w[t.second] += p;
      if (w[t.second] < h[t.second] + a[t.second] * m)
        q.push(make_pair(-w[t.second] / a[t.second], t.second));
    }
  }
  return q.empty();
}
int main() {
  read(n), read(m), read(k), read(p);
  long long l = 0, r = 0;
  for (int i = 1; i <= n; i++)
    read(h[i]), read(a[i]), r = max(r, a[i] * m + h[i]);
  while (l <= r) {
    long long mid = (l + r) >> 1;
    if (check(mid))
      r = mid - 1;
    else
      l = mid + 1;
  }
  printf("%lld\n", l);
}
