#include <bits/stdc++.h>
using namespace std;
struct ins {
  int ans;
  ins() { ans = 1; }
  void read() {}
  void read1(char &s) {
    char c = getchar();
    for (; !isprint(c) || c == ' ' || c == '\n' || c == '\t'; c = getchar())
      ;
    s = c;
    if (c == EOF) ans = 0;
  }
  void read1(string &s) {
    s = "";
    char c = getchar();
    for (; !isprint(c) || c == ' ' || c == '\n' || c == '\t'; c = getchar())
      ;
    for (; isprint(c) && c != ' ' && c != '\n' && c != '\t'; c = getchar())
      s += c;
    if (c == EOF) ans = 0;
  }
  template <typename T>
  void read1(T &n) {
    T x = 0;
    int f = 1;
    char c = getchar();
    for (; !isdigit(c); c = getchar()) {
      if (c == '-') f = -1;
      if (c == EOF) {
        ans = 0;
        return;
      }
    }
    for (; isdigit(c); c = getchar()) x = x * 10 + c - 48;
    n = x * f;
    if (c == EOF) ans = 0;
    if (c != '.') return;
    T l = 0.1;
    while ((c = getchar()) <= '9' && c >= '0') x = x + (c & 15) * l, l *= 0.1;
    n = x * f;
    if (c == EOF) ans = 0;
  }
  void write() {}
  void write1(string s) {
    int n = s.size();
    for (int i = 0; i < n; i++) putchar(s[i]);
  }
  void write1(const char *s) {
    int n = strlen(s);
    for (int i = 0; i < n; i++) putchar(s[i]);
  }
  void write1(char s) { putchar(s); }
  void write1(float s, int x = 6) {
    char y[10001];
    sprintf(y, "%%.%df", x);
    printf(y, s);
  }
  void write1(double s, int x = 6) {
    char y[10001];
    sprintf(y, "%%.%dlf", x);
    printf(y, s);
  }
  void write1(long double s, int x = 6) {
    char y[10001];
    sprintf(y, "%%.%dLf", x);
    printf(y, s);
  }
  template <typename T>
  void write1(T n) {
    if (n < 0) n = -n, putchar('-');
    if (n > 9) write1(n / 10);
    putchar('0' + n % 10);
  }
  template <typename T>
  friend ins operator>>(ins x, T &n);
  template <typename T>
  friend ins operator<<(ins x, T n);
  operator bool() { return ans; }
};
template <typename T>
ins operator>>(ins x, T &n) {
  if (!x.ans) return x;
  x.read1(n);
  return x;
}
template <typename T>
ins operator<<(ins x, T n) {
  x.write1(n);
  return x;
}
ins yin;
ins yout;
const int maxn = 2e5 + 10;
int n, m, k, c[maxn];
long long a[maxn], p, h[maxn];
priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
               greater<pair<long long, long long>>>
    q;
int check(long long x) {
  while (!q.empty()) q.pop();
  memset(c, 0, sizeof(c));
  for (int i = 1; i <= n; i++)
    if (x - a[i] * m < h[i]) q.push(make_pair(x / a[i], i));
  for (int i = 1; !q.empty() && i <= m; i++) {
    for (int j = 1; j <= k && !q.empty(); j++) {
      pair<long long, long long> tmp = q.top();
      q.pop();
      if (tmp.first < i) return 0;
      ++c[tmp.second];
      if (x + c[tmp.second] * p - a[tmp.second] * m < h[tmp.second]) {
        q.push(make_pair((x + c[tmp.second] * p) / a[tmp.second], tmp.second));
      }
    }
  }
  return q.empty();
}
int main() {
  long long l, r = 0;
  yin >> n >> m >> k >> p;
  for (int i = 1; i <= n; i++) yin >> h[i] >> a[i], r = max(r, h[i] + a[i] * m);
  l = 0;
  r++;
  while (l < r) {
    long long mid = l + r >> 1;
    if (check(mid))
      r = mid;
    else
      l = mid + 1;
  }
  yout << l << '\n';
  return 0;
}
