#include <bits/stdc++.h>
using namespace std;
template <class D>
inline void read(D &res) {
  res = 0;
  register D g = 1;
  register char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') g = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    res = (res << 3) + (res << 1) + (ch ^ 48);
    ch = getchar();
  }
  res *= g;
}
const long long INF = 1e16;
pair<long long, long long> nd;
long long P, n, m, k, p, h[101000], a[101000], b[101000];
priority_queue<pair<long long, long long>, vector<pair<long long, long long> >,
               greater<pair<long long, long long> > >
    q;
long long ck(long long x) {
  while (!q.empty()) q.pop();
  for (register long long i = 1; i <= n; i++) {
    if ((h[i] + a[i] * m) > x) {
      q.emplace(make_pair(x / a[i], i));
      b[i] = x;
    }
  }
  for (register long long i = 1; i <= m; i++) {
    if (q.empty()) return 1;
    if (q.top().first < i) return 0;
    for (register long long j = 1; j <= k; j++) {
      nd = q.top();
      q.pop();
      P = nd.second;
      b[P] += p;
      if (h[P] + a[P] * m > b[P]) q.emplace(make_pair(b[P] / a[P], P));
      if (q.empty()) return 1;
    }
  }
  if (q.empty()) return 1;
  return 0;
}
inline long long divided(long long x, long long y) {
  if (x == y) return x;
  register long long mid = (x + y) >> 1;
  if (ck(mid))
    y = mid;
  else
    x = mid + 1;
  return divided(x, y);
}
int main() {
  read(n);
  read(m);
  read(k);
  read(p);
  for (register long long i = 1; i <= n; i++) read(h[i]), read(a[i]);
  cout << divided(0, INF);
  return 0;
}
