#include <bits/stdc++.h>
using namespace std;
struct bamboo {
  long long x, h, a, deadline;
};
bool operator<(bamboo a, bamboo b) { return a.deadline > b.deadline; }
int get() {
  char c;
  while (c = getchar(), (c < '0' || c > '9') && (c != '-'))
    ;
  bool flag = (c == '-');
  if (flag) c = getchar();
  int x = 0;
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - 48;
    c = getchar();
  }
  return flag ? -x : x;
}
void output(int x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  int len = 0, data[10];
  while (x) {
    data[len++] = x % 10;
    x /= 10;
  }
  if (!len) data[len++] = 0;
  while (len--) putchar(data[len] + 48);
  putchar('\n');
}
const int maxn = 100000;
long long h[maxn], a[maxn];
long long calc(long long x, long long h, long long a, int m) {
  if (x / a < m) return x / a;
  if (x - a * m < h) return m;
  return m + 1;
}
bool check(int n, int m, int k, long long p, long long ans) {
  priority_queue<bamboo> all;
  while (!all.empty()) all.pop();
  for (int i = 0; i < n; i++)
    all.push((bamboo){ans, h[i], a[i], calc(ans, h[i], a[i], m)});
  for (int i = 0; i < m; i++)
    for (int j = 0; j < k; j++) {
      bamboo t = all.top();
      all.pop();
      if (t.deadline <= i) return false;
      t.x += p;
      t.deadline = calc(t.x, t.h, t.a, m);
      all.push(t);
    }
  return (all.top().deadline > m);
}
int main() {
  int n = get(), m = get(), k = get();
  long long p = get();
  for (int i = 0; i < n; i++) {
    h[i] = get();
    a[i] = get();
  }
  long long l = 0, r = 0;
  for (int i = 0; i < n; i++) r = max(r, h[i] + m * a[i]);
  while (l < r) {
    long long mid = (l + r) / 2;
    if (check(n, m, k, p, mid))
      r = mid;
    else
      l = mid + 1;
  }
  cout << l << endl;
  return 0;
}
