#include <bits/stdc++.h>
using namespace std;
namespace io {
const int SI = 1 << 21 | 1;
char IB[SI], *IS, *IT, OB[SI], *OS = OB, *OT = OS + SI - 1, c, ch[100];
int f, t;
inline void flush() { fwrite(OB, 1, OS - OB, stdout), OS = OB; }
inline void pc(char x) {
  *OS++ = x;
  if (OS == OT) flush();
}
template <class I>
inline void rd(I &x) {
  for (f = 1, c = (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin),
                              IS == IT ? EOF : *IS++)
                            : *IS++);
       c < '0' || c > '9';
       c = (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin),
                       IS == IT ? EOF : *IS++)
                     : *IS++))
    if (c == '-') f = -1;
  for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15),
      c = (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin),
                      IS == IT ? EOF : *IS++)
                    : *IS++))
    ;
  x *= f;
}
inline void rds(char *s, int &x) {
  for (c = (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin),
                       IS == IT ? EOF : *IS++)
                     : *IS++);
       c < 33 || c > 126;
       c = (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin),
                       IS == IT ? EOF : *IS++)
                     : *IS++))
    ;
  for (x = 0; c >= 33 && c <= 126;
       s[++x] = c, c = (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin),
                                   IS == IT ? EOF : *IS++)
                                 : *IS++))
    ;
  s[x + 1] = '\0';
}
template <class I>
inline void print(I x, char k = '\n') {
  if (!x) pc('0');
  if (x < 0) pc('-'), x = -x;
  while (x) ch[++t] = x % 10 + '0', x /= 10;
  while (t) pc(ch[t--]);
  pc(k);
}
inline void prints(string s) {
  int x = s.length();
  while (t < x) pc(s[t++]);
  pc('\n'), t = 0;
}
struct Flush {
  ~Flush() { flush(); }
} flusher;
}  // namespace io
using io::print;
using io::prints;
using io::rd;
using io::rds;
const int N = 1e5 + 7;
int n, m, k, c[N];
long long h[N], a[N], p, l, r;
inline bool pd(long long o) {
  priority_queue<pair<int, int> > q;
  for (int i = 1; i <= n; i++) {
    if (h[i] + m * a[i] <= o) continue;
    q.push(make_pair(-(o / a[i]), i)), c[i] = 0;
  }
  int cnt = 0;
  for (int i = 1; q.size() && i <= m; i++)
    for (int j = 1; q.size() && j <= k; j++) {
      if (-q.top().first < i) return 0;
      int x = q.top().second;
      q.pop();
      long long w = (o + (++c[x]) * p) / a[x];
      if (w < m) q.push(make_pair(-w, x));
      ++cnt;
    }
  for (int i = 1; i <= n; i++) {
    long long w = o + c[i] * p - m * a[i];
    if (h[i] <= w) continue;
    w = (h[i] - w - 1) / p + 1;
    if (cnt + w > m * k) return 0;
    cnt += w;
  }
  return 1;
}
int main() {
  rd(n), rd(m), rd(k), rd(p);
  for (int i = 1; i <= n; i++)
    rd(h[i]), rd(a[i]), l = max(l, a[i]), r = max(r, h[i] + m * a[i]);
  while (l < r) {
    long long o = (l + r) >> 1;
    if (pd(o))
      r = o;
    else
      l = o + 1;
  }
  print(l);
  return 0;
}
