#include <bits/stdc++.h>
using namespace std;
long long p1 = 1000000, p2 = 0;
char buf[1000005], wb[1000005];
long long gc() {
  if (p1 >= 1000000) fread(buf, 1, 1000000, stdin), p1 = 0;
  return buf[p1++];
}
long long getint() {
  long long ret = 0, flag = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') flag = -1;
    c = getchar();
  }
  while (c <= '9' && c >= '0') {
    ret = (ret << 3) + (ret << 1) + c - '0';
    c = getchar();
  }
  return ret * flag;
}
void pc(char x) {
  if (p2 >= 1000000) fwrite(wb, 1, 1000000, stdout), p2 = 0;
  wb[p2++] = x;
}
void wrt(long long x) {
  if (x < 0) pc('-'), x = -x;
  long long c[24] = {0};
  if (!x) return pc('0'), void();
  while (x) c[++c[0]] = x % 10, x /= 10;
  while (c[0]) pc(c[c[0]--] + '0');
}
long long n, m, k, p;
long long c[100005];
long long h[100005], a[100005];
struct node {
  long long day, id;
  node(long long _day = 0, long long _id = 0) { day = _day, id = _id; }
  bool operator<(const node b) const { return day > b.day; }
};
bool check(long long x) {
  priority_queue<node> q;
  memset(c, 0, sizeof(c));
  for (long long i = 1; i <= n; i++)
    if (x - a[i] * m < h[i]) q.push(node(x / a[i], i));
  for (long long i = 1; !q.empty() && i <= m; i++) {
    for (long long j = 1; !q.empty() && j <= k; j++) {
      if (q.top().day < i) return 0;
      node tmp = q.top();
      q.pop();
      if (x + (++c[tmp.id]) * p - a[tmp.id] * m < h[tmp.id])
        q.push(node((x + c[tmp.id] * p) / a[tmp.id], tmp.id));
    }
  }
  return q.empty();
}
signed main() {
  n = getint();
  m = getint();
  k = getint();
  p = getint();
  for (long long i = 1; i <= n; i++) h[i] = getint(), a[i] = getint();
  long long l = 0, r = 2e18;
  while (l <= r) {
    long long mid = (l + r) >> 1;
    if (check(mid))
      r = mid - 1;
    else
      l = mid + 1;
  }
  wrt(r + 1), pc('\n');
  fwrite(wb, 1, p2, stdout);
  return 0;
}
