#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  while (c > '9' || c < '0') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + (c - '0');
    c = getchar();
  }
  return x * f;
}
const long long maxn = 1e5 + 10;
long long n, m, Q, f[maxn], k, a[maxn], h[maxn];
struct node {
  long long val, num;
  friend bool operator<(const node &x, const node &y) { return x.val > y.val; }
};
bool check(long long mid) {
  priority_queue<node> q;
  for (long long i = 1; i <= n; i++) {
    f[i] = mid;
    if (mid - m * a[i] < h[i]) q.push((node){mid / a[i], i});
  }
  for (long long i = 1; i <= m && !q.empty(); i++)
    for (long long j = 1; j <= Q && !q.empty(); j++) {
      node tmp = q.top();
      q.pop();
      long long x = tmp.num;
      if (f[x] - a[x] * i < 0) return 0;
      f[x] += k;
      if (f[x] - a[x] * m < h[x]) q.push((node){f[x] / a[x], x});
    }
  for (long long i = 1; i <= n; i++)
    if (f[i] - a[i] * m < h[i]) return 0;
  return 1;
}
signed main() {
  n = read(), m = read(), Q = read(), k = read();
  long long maxx = 0;
  for (long long i = 1; i <= n; i++) {
    h[i] = read(), a[i] = read();
    maxx = max(maxx, a[i] * m + h[i]);
  }
  long long l = 0, r = maxx;
  long long ans = 1e18;
  while (l <= r) {
    long long mid = (l + r) >> 1;
    if (check(mid)) {
      ans = min(ans, mid);
      r = mid - 1;
    } else
      l = mid + 1;
  }
  printf("%lld\n", ans);
  return 0;
}
