#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
inline long long read() {
  char c = getchar();
  long long x = 0;
  bool f = 0;
  for (; !isdigit(c); c = getchar()) f ^= !(c ^ 45);
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
  if (f) x = -x;
  return x;
}
long long n, m, k, p;
long long cnt[100005], a[100005], h[100005], mid;
struct cmp {
  bool operator()(long long x, long long y) {
    return (mid + cnt[x] * p) / a[x] > (mid + cnt[y] * p) / a[y];
  }
};
priority_queue<long long, vector<long long>, cmp> q;
bool check() {
  priority_queue<long long, vector<long long>, cmp> q;
  memset(cnt, 0, sizeof cnt);
  for (register long long i = (1); i <= (n); ++i)
    if (mid - a[i] * m < h[i]) q.push(i);
  if (q.empty()) return 1;
  for (register long long i = (1); i <= (m); ++i) {
    for (register long long j = (1); j <= (k); ++j) {
      long long u = q.top();
      q.pop();
      if ((mid + cnt[u] * p) / a[u] < i) return 0;
      cnt[u]++;
      if (mid + cnt[u] * p - a[u] * m < h[u]) q.push(u);
      if (q.empty()) return 1;
    }
    if (q.empty()) return 1;
  }
  return q.empty();
}
signed main() {
  n = read(), m = read(), k = read(), p = read();
  long long l = 0, r = 0;
  for (register long long i = (1); i <= (n); ++i)
    h[i] = read(), a[i] = read(), r = max(r, h[i] + a[i] * m);
  long long res = 2e9;
  while (l <= r) {
    mid = l + r >> 1;
    if (check())
      res = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  cout << res;
  return 0;
}
