#include <bits/stdc++.h>
using namespace std;
int n, m, k;
long long p, h[100005], a[100005], now[100005];
struct node {
  long long d;
  int id;
  friend bool operator<(node x, node y) { return x.d > y.d; }
};
priority_queue<node> q;
bool check(long long x) {
  while (!q.empty()) q.pop();
  for (int i = 1; i <= n; i++) {
    now[i] = x;
    if (now[i] - a[i] * m < h[i]) q.push(node{now[i] / a[i] + 1, i});
  }
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= k; j++) {
      if (q.empty()) return 1;
      int t = q.top().id;
      if (q.top().d <= i) return 0;
      q.pop();
      now[t] += p;
      if (now[t] - a[t] * m < h[t]) q.push(node{now[t] / a[t] + 1, t});
    }
  }
  return q.empty();
}
int main() {
  scanf("%d%d%d%lld", &n, &m, &k, &p);
  for (int i = 1; i <= n; i++) scanf("%lld%lld", &h[i], &a[i]);
  long long l = 0, r = 1e15;
  while (l < r) {
    long long mid = (l + r) >> 1;
    if (check(mid))
      r = mid;
    else
      l = mid + 1;
  }
  printf("%lld", l);
  return 0;
}
