#include <bits/stdc++.h>
using namespace std;
long long ans, a[100010], nowh[100010], h[100010], n, m, K, P;
struct data {
  long long val, id;
};
bool operator<(data a, data b) { return a.val < b.val; }
bool operator>(data a, data b) { return a.val > b.val; }
struct Heap {
  data hp[100010];
  long long cnt;
  void Up(long long pos) {
    while (pos > 1 && hp[pos] < hp[pos / 2]) {
      swap(hp[pos], hp[pos / 2]);
      pos = pos / 2;
    }
  }
  void Down(long long pos) {
    for (long long p;;) {
      p = pos;
      if (pos * 2 <= cnt && hp[pos * 2] < hp[p]) p = pos * 2;
      if (pos * 2 + 1 <= cnt && hp[pos * 2 + 1] < hp[p]) p = pos * 2 + 1;
      if (p == pos) return;
      swap(hp[p], hp[pos]);
      pos = p;
    }
  }
  void push(data x) {
    hp[++cnt] = x;
    Up(cnt);
  }
  data top() { return hp[1]; }
  bool empty() { return cnt == 0; }
  void pop() {
    if (cnt == 1) {
      cnt = 0;
      hp[1] = (data){0, 0};
      return;
    }
    hp[1] = hp[cnt--];
    hp[cnt + 1] = (data){0, 0};
    Down(1);
  }
} heap;
bool OK(long long LastH) {
  while (!heap.empty()) heap.pop();
  for (long long i = 1; i <= n; i++) nowh[i] = LastH;
  for (long long i = 1; i <= n; i++) {
    if (nowh[i] - m * a[i] >= 0)
      continue;
    else
      heap.push((data){nowh[i] / a[i] - 1, i});
  }
  long long tot = 0;
  for (; tot <= m * K; tot++) {
    if (heap.empty()) break;
    data now = heap.top();
    heap.pop();
    if (now.val < tot / K) return 0;
    nowh[now.id] += P;
    if (nowh[now.id] - m * a[now.id] >= 0)
      continue;
    else
      heap.push((data){nowh[now.id] / a[now.id] - 1, now.id});
  }
  if (tot > K * m) return 0;
  for (long long i = 1; i <= n; i++) {
    if (nowh[i] - m * a[i] >= h[i]) continue;
    tot += ((h[i] - nowh[i] + m * a[i]) + P - 1) / P;
    if (tot > K * m) return 0;
  }
  return 1;
}
int main() {
  scanf("%I64d%I64d%I64d%I64d", &n, &m, &K, &P);
  for (long long i = 1; i <= n; i++) scanf("%I64d%I64d", &h[i], &a[i]);
  long long l = 0, r = 1e15, ans = -1;
  while (l <= r) {
    long long mid = (l + r) / 2;
    if (OK(mid)) {
      ans = mid;
      r = mid - 1;
    } else
      l = mid + 1;
  }
  printf("%I64d", ans);
}
