#include <bits/stdc++.h>
using namespace std;
template <class T>
T gi() {
  T x = 0;
  bool f = 0;
  char c = getchar();
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  if (c == '-') f = 1, c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return f ? -x : x;
}
const int N = 1e5 + 10;
long long a[N], h[N], b[N];
int n, m, k, p;
bool check(long long x) {
  priority_queue<pair<long long, int>, vector<pair<long long, int> >,
                 greater<pair<long long, int> > >
      q;
  for (int i = 1; i <= n; i++) {
    b[i] = x;
    if (x - m * a[i] < h[i]) q.push(make_pair(x / a[i], i));
  }
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= k; j++) {
      if (q.empty()) return 1;
      if (q.top().first < i) return 0;
      int pos = q.top().second;
      q.pop();
      b[pos] += p;
      if (b[pos] - m * a[pos] < h[pos]) q.push(make_pair(b[pos] / a[pos], pos));
    }
  return q.empty();
}
int main() {
  n = gi<int>(), m = gi<int>(), k = gi<int>(), p = gi<int>();
  for (int i = 1; i <= n; i++) h[i] = gi<long long>(), a[i] = gi<long long>();
  long long l = 0, r = 1e15;
  while (l <= r) {
    long long mid = (l + r) >> 1;
    if (check(mid))
      r = mid - 1;
    else
      l = mid + 1;
  }
  printf("%lld\n", r + 1);
  return 0;
}
