#include <bits/stdc++.h>
using namespace std;
const int N = 100100;
int n, k, m, p;
long long b[N];
pair<int, int> a[N];
set<pair<long long, int> > S;
bool chk(long long x) {
  long long sum = 0;
  for (int i = 1; i <= n; ++i) {
    b[i] = x;
    long long ret = (a[i].first - (b[i] - (long long)m * a[i].second));
    ret = max(ret, 0ll);
    sum += (ret + p - 1) / p;
  }
  if (sum > m * k) return 0;
  S.clear();
  for (int i = 1; i <= n; ++i) S.emplace(b[i] / a[i].second, i);
  for (int i = m; i; --i) {
    if (S.begin()->first <= m - i) return 0;
    for (int j = 1; j <= k; ++j) {
      int x = S.begin()->second;
      S.erase(S.begin());
      b[x] += p;
      S.emplace(b[x] / a[x].second, x);
    }
  }
  return 1;
}
int main() {
  cin >> n >> m >> k >> p;
  for (int i = 1; i <= n; ++i) cin >> a[i].first >> a[i].second;
  long long l = 0, r = 1e18;
  while (l < r) {
    long long mid = (l + r) / 2;
    if (chk(mid))
      r = mid;
    else
      l = mid + 1;
  }
  cout << l << '\n';
  return 0;
}
