#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  int v = 0, f = 1;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = (c & 15);
  while (isdigit(c = getchar())) v = (v << 1) + (v << 3) + (c & 15);
  x = v * f;
}
inline void read(long long &x) {
  long long v = 0ll, f = 1ll;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = (c & 15);
  while (isdigit(c = getchar())) v = (v << 1) + (v << 3) + (c & 15);
  x = v * f;
}
inline void readc(char &x) {
  char c;
  while (((c = getchar()) == ' ') || c == '\n')
    ;
  x = c;
}
int n, m, k, i, j, c[100005];
long long p, l, r, mid, ans, a[100005], h[100005];
priority_queue<pair<long long, int>, vector<pair<long long, int> >,
               greater<pair<long long, int> > >
    pq;
bool check(long long x) {
  int i;
  while (!pq.empty()) pq.pop();
  for (((i)) = (1); ((i)) <= ((n)); ((i))++) {
    c[i] = 0;
    if (x - m * a[i] < h[i]) {
      pq.push(make_pair(x / a[i], i));
    }
  }
  for (((i)) = (1); ((i)) <= ((m)); ((i))++) {
    for (((j)) = (1); ((j)) <= ((k)); ((j))++) {
      if (pq.empty()) return 1;
      pair<long long, int> t = pq.top();
      pq.pop();
      if (t.first < i) return 0;
      c[t.second]++;
      if (x + c[t.second] * p - a[t.second] * m < h[t.second]) {
        pq.push(make_pair((x + c[t.second] * p) / a[t.second], t.second));
      }
    }
  }
  return pq.empty();
}
int main() {
  read(n);
  read(m);
  read(k);
  read(p);
  for (((i)) = (1); ((i)) <= ((n)); ((i))++) {
    read(h[i]);
    read(a[i]);
    r = max(r, 1ll * a[i] * m + h[i]);
  }
  l = -1;
  ans = r;
  while (l < r) {
    mid = (l + r + 1) / 2;
    if (check(mid)) {
      r = mid - 1;
      ans = mid;
    } else
      l = mid;
  }
  cout << ans << endl;
  return 0;
}
