#include <bits/stdc++.h>
using namespace std;
long long n, m, k, p, h[100010], a[100010], need[100010], ans[100010];
inline bool check(long long val) {
  long long res = 0;
  memset(ans, 0, sizeof(ans));
  for (int i = 0; i < n; i++) {
    need[i] = max(0ll, (h[i] - (val - m * a[i]) + p - 1) / p);
    res += need[i];
  }
  if (res > m * k) return false;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < need[i]; j++) ans[min(m, (val + j * p) / a[i])]--;
  if (ans[0]) return false;
  for (int i = 1; i <= m; i++) {
    ans[i] += ans[i - 1] + k;
    if (ans[i] < 0) return false;
  }
  return true;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> k >> p;
  for (int i = 0; i < n; i++) cin >> h[i] >> a[i];
  long long lo = -1, hi = 1e18;
  while (lo != (hi - 1)) {
    long long mid = lo + hi >> 1;
    if (check(mid))
      hi = mid;
    else
      lo = mid;
  }
  cout << hi << endl;
  return 0;
}
