#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
inline long long read() {
  char ch = getchar();
  long long x = 0, f = 0;
  while (ch < '0' || ch > '9') f |= ch == '-', ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return f ? -x : x;
}
int n, m, k, p, h[maxn], a[maxn], cnt[maxn], at;
vector<int> v[maxn];
bool yet_another_check(long long x, int rem) {
  long long sum = 0;
  for (int i = (1); i <= (n); i++)
    sum += max(0ll, (h[i] + 1ll * m * a[i] - x + p - 1) / p - cnt[i]);
  return sum <= rem;
}
bool check(long long x) {
  for (int i = (1); i <= (m); i++) v[i].clear();
  for (int i = (1); i <= (n); i++) {
    cnt[i] = 0;
    long long d = x / a[i] + 1;
    if (d <= m) v[d].push_back(i);
  }
  at = 0;
  for (int i = (1); i <= (m); i++) {
    while (at <= m && v[at].empty()) at++;
    if (at > m) return yet_another_check(x, k * (m - i + 1));
    if (at <= i) return false;
    for (int j = (1); j <= (k); j++) {
      int id = v[at].back();
      v[at].pop_back();
      while (at <= m && v[at].empty()) at++;
      if (at > m) return yet_another_check(x, k - j + 1 + k * (m - i));
      cnt[id]++;
      long long d = (x + 1ll * cnt[id] * p) / a[id] + 1;
      if (d <= m) v[d].push_back(id);
    }
  }
  return yet_another_check(x, 0);
}
int main() {
  n = read();
  m = read();
  k = read();
  p = read();
  for (int i = (1); i <= (n); i++) h[i] = read(), a[i] = read();
  long long l = 0, r = 2e14;
  while (l < r) {
    long long mid = (l + r) >> 1;
    if (check(mid))
      r = mid;
    else
      l = mid + 1;
  }
  printf("%lld\n", l);
}
