#include <bits/stdc++.h>
using namespace std;
const int inf = ~0U >> 1;
const long long INF = ~0ULL >> 1;
template <class T>
inline void read(T &n) {
  char c;
  for (c = getchar(); !(c >= '0' && c <= '9'); c = getchar())
    ;
  n = c - '0';
  for (c = getchar(); c >= '0' && c <= '9'; c = getchar()) n = n * 10 + c - '0';
}
int Pow(int base, int n, int mo) {
  if (n == 0) return 1;
  if (n == 1) return base % mo;
  int tmp = Pow(base, n >> 1, mo);
  tmp = (long long)tmp * tmp % mo;
  if (n & 1) tmp = (long long)tmp * base % mo;
  return tmp;
}
const int maxn = 120000;
int h[maxn], a[maxn], extra[maxn];
long long sum[maxn];
int N, M, K, P;
priority_queue<pair<int, int>, vector<pair<int, int> >,
               greater<pair<int, int> > >
    heap;
int check(long long mh) {
  long long s = 0;
  for (int i = (1); i <= (N); ++i) {
    long long t = max((long long)h[i] + (long long)a[i] * M - mh, 0ll);
    long long cur = t / P + bool(t % P);
    s += cur;
  }
  if (s > M * K) return 0;
  memset(sum, 0, sizeof(sum));
  while (heap.size()) heap.pop();
  int cnt = 0;
  for (int i = (1); i <= (N); ++i)
    if (mh / a[i] + 1 <= M)
      heap.push((make_pair(mh / a[i] + 1, i)));
    else if (mh - (long long)a[i] * M < h[i])
      extra[++cnt] = i;
  for (int i = (M); i >= (1); --i) {
    for (int j = (1); j <= (K); ++j) {
      if (!heap.size()) {
        if (!cnt) break;
        int t = extra[cnt--];
        sum[t] += P;
        if (mh + sum[t] - (long long)a[t] * M < h[t]) extra[++cnt] = t;
      } else {
        pair<int, int> t = heap.top();
        heap.pop();
        if (t.first > M - i + 1) {
          sum[t.second] += P;
          t.first = (mh + sum[t.second]) / a[t.second] + 1;
          if (t.first <= M)
            heap.push(t);
          else if (mh + sum[t.second] - (long long)a[t.second] * M <
                   h[t.second])
            extra[++cnt] = t.second;
        } else
          return 0;
      }
    }
  }
  return !cnt && !heap.size();
}
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 = 6000000000000LL;
  while (l + 1 < r) {
    long long m = l + r >> 1;
    if (check(m))
      r = m;
    else
      l = m + 1;
  }
  while (!check(l)) l++;
  printf("%lld\n", l);
  return 0;
}
