#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
long long R() {
  long long ans = 0, f = 1;
  char c = getchar();
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') f = -1;
  for (; c >= '0' && c <= '9'; c = getchar()) ans = ans * 10 + c - '0';
  return ans * f;
}
int n, m, K, P;
long long a[N], h[N], b[N];
priority_queue<pair<int, int>, vector<pair<int, int> >,
               greater<pair<int, int> > >
    d;
bool ck(long long H) {
  while (!d.empty()) d.pop();
  for (int i = 1; i <= n; ++i) b[i] = 0;
  for (int i = 1; i <= n; ++i)
    if (H - m * a[i] < h[i]) d.push(make_pair(H / a[i], i));
  for (int i = 0; i <= m - 1; ++i) {
    for (int r = 1; r <= K; ++r) {
      if (d.empty()) return 1;
      int p = d.top().second;
      d.pop();
      if (b[p] + H - (i + 1) * a[p] < 0) return 0;
      b[p] += P;
      if (H + b[p] - m * a[p] < h[p]) d.push(make_pair((H + b[p]) / a[p], p));
    }
  }
  return d.empty();
}
int main() {
  n = R();
  m = R();
  K = R();
  P = R();
  for (int i = 1; i <= n; ++i) h[i] = R(), a[i] = R();
  long long ll = 0, rr = 1000000100000000000ll, mid, ans;
  while (ll <= rr) {
    mid = (ll + rr) / 2;
    if (ck(mid))
      ans = mid, rr = mid - 1;
    else
      ll = mid + 1;
  }
  cout << ans << '\n';
  return 0;
}
