#include <bits/stdc++.h>
using namespace std;
int H[100010], A[100010], ss[100010];
struct SJd {
  int i;
  long long z;
  SJd() {}
  SJd(int I, long long Z) {
    z = Z;
    i = I;
  }
};
bool operator<(const SJd &a, const SJd &b) { return a.z < b.z; }
bool check(int n, int m, int k, int p, long long x) {
  priority_queue<SJd> pq;
  for (int i = 1; i <= n; i++) {
    ss[i] = 0;
    if (x - 1ll * m * A[i] < H[i]) pq.push(SJd(i, m + 1 - x / A[i]));
  }
  for (int i = m; i >= 1; i--) {
    for (int j = 0; j < k; j++) {
      if (pq.empty()) return true;
      SJd t = pq.top();
      pq.pop();
      if (t.z > i) return false;
      int w = t.i;
      ss[w] += 1;
      long long z = x + 1ll * p * ss[w] - 1ll * (m - i + 1) * A[w];
      if (z - 1ll * (i - 1) * A[w] < H[w]) pq.push(SJd(w, i - z / A[w]));
    }
  }
  return pq.empty();
}
int main() {
  int n, m, k, p;
  scanf("%d%d%d%d", &n, &m, &k, &p);
  long long l = 0, r = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &H[i], &A[i]);
    long long t = H[i] + 1ll * m * A[i];
    if (t > r) r = t;
    if (A[i] > l) l = A[i];
  }
  while (l < r) {
    long long x = (l + r) >> 1;
    if (check(n, m, k, p, x))
      r = x;
    else
      l = x + 1;
  }
  printf("%lld", l);
  return 0;
}
