#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, K;
long long m, P, h[N], a[N], s[N];
queue<int> que[N];
template <class T>
inline T Read(T &r) {
  int b = 1, c = getchar();
  r = 0;
  while (c < '0' || '9' < c) b = c == '-' ? -1 : b, c = getchar();
  while ('0' <= c && c <= '9')
    r = (r << 1) + (r << 3) + (c ^ '0'), c = getchar();
  return r *= b;
}
long long Upper(long long x, long long y) {
  if (x < 0) return 0;
  return (x + y - 1) / y;
}
bool Check(long long L) {
  for (int i = 1; i <= m; i++)
    while (!que[i].empty()) que[i].pop();
  for (int i = 1; i <= n; i++) s[i] = 0, que[m].push(i);
  long long rem = 0;
  for (int j = m; j >= 1; j--) {
    rem += K;
    if (j > 1)
      while (!que[j].empty()) {
        int i = que[j].front();
        que[j].pop();
        long long nxt = Upper((m - j + 2) * a[i] - L, P);
        rem -= nxt - s[i];
        assert(s[i] <= nxt);
        s[i] = nxt;
        long long x = (s[i] * P + L) / a[i] + 1;
        x = m - x + 2;
        assert(x < j);
        if (x > 1) que[x].push(i);
      }
    else
      for (int i = 1; i <= n; i++) {
        long long nxt = Upper(h[i] + m * a[i] - L, P);
        assert(nxt >= s[i]);
        rem -= nxt - s[i];
      }
    if (rem < 0) return false;
  }
  return true;
}
int main() {
  Read(n), Read(m), Read(K), Read(P);
  long long lef = 0, rig = 0;
  for (int i = 1; i <= n; i++) {
    Read(h[i]), Read(a[i]);
    lef = max(lef, a[i]);
    rig = max(rig, m * a[i] + h[i]);
  }
  while (lef + 1 < rig) {
    long long mid = (lef + rig) >> 1;
    if (Check(mid))
      rig = mid;
    else
      lef = mid;
  }
  if (Check(lef))
    printf("%lld\n", lef);
  else
    printf("%lld\n", rig);
  return 0;
}
