#include <bits/stdc++.h>
const int MAXN = 2e6;
long long get_int() {
  long long x = 0, y = 1;
  char ch = getchar();
  while (!isdigit(ch) && ch != '-') ch = getchar();
  if (ch == '-') y = -1, ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return x * y;
}
long long plus[MAXN], m, n, k, p, h[MAXN], a[MAXN];
class Heap {
 public:
  long long height, index;
} heap[MAXN];
long long hNum;
long long operator<(const Heap& a1, const Heap& b) {
  long long valueA = (a1.height + plus[a1.index] * p) / a[a1.index];
  long long valueB = (b.height + plus[b.index] * p) / a[b.index];
  return valueA > valueB;
}
long long check(long long mid) {
  memset(plus, 0, sizeof(plus));
  hNum = 0;
  for (long long i = 0; i < n; i++) {
    if ((mid - h[i]) / a[i] < m) {
      heap[hNum].height = mid;
      heap[hNum].index = i;
      hNum++;
    }
  }
  if (hNum == 0) return 1;
  std::make_heap(heap, heap + hNum);
  for (long long i = 0; i < m; i++) {
    for (long long j = 0; j < k; j++) {
      long long index = heap[0].index, height = heap[0].height;
      std::pop_heap(heap, heap + hNum);
      hNum--;
      if (((height + plus[index] * p) / a[index]) < i + 1) return false;
      plus[index]++;
      if (height + plus[index] * p - a[index] * m < h[index]) {
        std::push_heap(heap, heap + hNum);
        hNum++;
      }
      if (hNum == 0) return true;
    }
  }
  return hNum == 0;
}
signed main() {
  n = get_int(), m = get_int(), k = get_int(), p = get_int();
  for (long long i = 0; i < n; i++) {
    h[i] = get_int();
    a[i] = get_int();
  }
  long long l = 0, r = 1e16, ans = -1;
  while (l <= r) {
    long long mid = (l + r) / 2;
    if (check(mid) == true) {
      r = mid - 1;
      ans = mid;
    } else {
      l = mid + 1;
    }
  }
  std::cout << ans;
  return 0;
}
