#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
struct node {
  long long remain;
  int id;
  bool operator<(const node &b) const { return remain > b.remain; }
};
priority_queue<node> q;
int n, m, k, p, h[N], a[N], cnt[N];
inline bool check(long long mid) {
  memset(cnt, 0, sizeof(cnt));
  while (!q.empty()) q.pop();
  for (int i = 1; i <= n; i++)
    if (mid - (long long)a[i] * m < h[i]) q.push((node){mid / a[i], i});
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= k; j++) {
      if (q.empty()) return true;
      node u = q.top();
      q.pop(), cnt[u.id]++;
      if (u.remain < i) return false;
      if (mid + (long long)cnt[u.id] * p - (long long)a[u.id] * m < h[u.id])
        q.push((node){(mid + (long long)cnt[u.id] * p) / a[u.id], u.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, mid, ans = -1;
  while (l <= r) {
    mid = (l + r) >> 1;
    if (check(mid))
      r = mid - 1, ans = mid;
    else
      l = mid + 1;
  }
  printf("%lld\n", ans);
}
