#include <bits/stdc++.h>
using namespace std;
int n, m, K, p, h[100010], a[100010];
class bam {
 public:
  long long day;
  int id;
  bool operator<(const bam &x) const { return day > x.day; }
};
priority_queue<bam> q;
int f[100010];
bool check(long long x) {
  while (!q.empty()) q.pop();
  memset(f, 0, sizeof(f));
  for (int i = 1; i <= n; i++)
    if (x - 1ll * a[i] * m < h[i]) q.push((bam){x / a[i], i});
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= K; j++) {
      if (q.empty()) return 1;
      bam cur = q.top();
      q.pop();
      if (cur.day < i) return 0;
      if (x + 1ll * p * (++f[cur.id]) - 1ll * m * a[cur.id] < h[cur.id])
        q.push((bam){(x + 1ll * p * f[cur.id]) / a[cur.id], cur.id});
    }
  }
  return q.empty();
}
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 = R + 1;
  while (L <= R) {
    long long mid = (L + R) >> 1;
    if (check(mid))
      ans = mid, R = mid - 1;
    else
      L = mid + 1;
  }
  printf("%lld\n", ans);
  return 0;
}
