#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
struct node {
  long long scnt;
  int id;
  bool operator<(const node &b) const { return scnt > b.scnt; }
};
priority_queue<node> que;
int n, m, k, p;
int a[maxn], h[maxn], cnt[maxn];
bool check(long long lst) {
  for (int i = 1; i <= n; i++) {
    if (h[i] + m * 1LL * a[i] - lst > 0) que.push((node){lst / a[i], i});
    cnt[i] = 0;
  }
  for (int i = 1; i <= m; i++)
    for (int t = 1; t <= k; t++) {
      if (que.empty()) return true;
      node now = que.top();
      que.pop();
      cnt[now.id]++;
      if (now.scnt < i) {
        while (!que.empty()) que.pop();
        return false;
      }
      if (lst + cnt[now.id] * 1LL * p - a[now.id] * 1LL * m < h[now.id])
        que.push((node){(lst + cnt[now.id] * 1LL * p) / a[now.id], now.id});
    }
  if (que.empty()) return true;
  while (!que.empty()) que.pop();
  return false;
}
int main() {
  scanf("%d%d%d%d", &n, &m, &k, &p);
  for (int i = 1; i <= n; i++) scanf("%d%d", &h[i], &a[i]);
  long long l = 0, r = 1e15, ans = 1e15;
  while (l <= r) {
    long long mid = l + r >> 1;
    if (check(mid))
      r = mid - 1, ans = mid;
    else
      l = mid + 1;
  }
  printf("%lld\n", ans);
}
