#include <bits/stdc++.h>
using namespace std;
int read() {
  bool f = 0;
  int x = 0;
  char c = getchar();
  while (c < '0' || '9' < c) {
    if (c == '-') f = 1;
    c = getchar();
  }
  while ('0' <= c && c <= '9')
    x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  return !f ? x : -x;
}
const int MAXN = 100000;
const int INF = 0x3f3f3f3f;
long long n, m, k, p;
long long h[MAXN + 5], a[MAXN + 5];
queue<pair<int, int> > q[MAXN + 5];
bool check(long long x) {
  for (int i = 1; i <= m; i++)
    while (!q[i].empty()) q[i].pop();
  for (int i = 1; i <= n; i++) {
    long long s = x / a[i] + 1;
    if (s <= m) q[s].push(make_pair(i, 0));
  }
  for (int i = 1, c = 0; i <= m; i++, c += k) {
    while (!q[i].empty()) {
      if (!c) return 0;
      c--;
      pair<int, int> u = q[i].front();
      q[i].pop(), u.second++;
      long long s = (u.second * p + x) / a[u.first] + 1;
      if (s <= m) q[s].push(u);
    }
  }
  long long s = 0;
  for (int i = 1; i <= n; i++) s += (max(h[i] + a[i] * m - x, 0ll) + p - 1) / p;
  return s <= m * k;
}
int main() {
  n = read(), m = read(), k = read(), p = read();
  long long L = 0, R = 0;
  for (int i = 1; i <= n; i++)
    h[i] = read(), a[i] = read(), R = max(R, h[i] + m * a[i]);
  while (L + 1 < R) {
    long long Mid = (L + R) >> 1;
    if (check(Mid))
      R = Mid;
    else
      L = Mid;
  }
  printf("%lld\n", R);
  return 0;
}
