#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + ch - '0';
    ch = getchar();
  }
  return x * f;
}
long long n, m, k, p, h[N], a[N], l, r, ans, cnt[N];
struct node {
  long long id, day;
  bool operator<(const node &rhs) const { return day > rhs.day; }
};
bool check(long long x) {
  priority_queue<node> q;
  memset(cnt, 0, sizeof(cnt));
  for (int i = 1; i <= n; i++)
    if (x - a[i] * m < h[i]) q.push((node){i, x / a[i]});
  for (int i = 1; i <= m && !q.empty(); i++) {
    for (int j = 1; j <= k && !q.empty(); j++) {
      node u = q.top();
      q.pop();
      if (u.day < i) return 0;
      cnt[u.id]++;
      if (x + cnt[u.id] * p - a[u.id] * m < h[u.id])
        q.push((node){u.id, (x + cnt[u.id] * p) / a[u.id]});
    }
  }
  return q.empty();
}
int main() {
  n = read(), m = read(), k = read(), p = read();
  for (int i = 1; i <= n; i++)
    h[i] = read(), a[i] = read(), r = max(r, h[i] + a[i] * m);
  while (l <= r) {
    long long mid = (l + r) / 2;
    if (check(mid))
      ans = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  printf("%lld", ans);
  return 0;
}
