#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
inline bool smax(A &a, const B &b) {
  return a < b ? a = b, 1 : 0;
}
template <typename A, typename B>
inline bool smin(A &a, const B &b) {
  return b < a ? a = b, 1 : 0;
}
template <typename I>
inline void read(I &x) {
  int f = 0, c;
  while (!isdigit(c = getchar())) c == '-' ? f = 1 : 0;
  x = c & 15;
  while (isdigit(c = getchar())) x = (x << 1) + (x << 3) + (c & 15);
  f ? x = -x : 0;
}
const int N = 1e5 + 7;
const int M = 5e3 + 7;
int n, m, k, p;
int a[N], h[N];
long long c[N];
std::vector<int> v[M];
inline bool check(long long mid) {
  for (int i = 1; i <= m; ++i) v[i].clear();
  for (int i = 1; i <= n; ++i)
    if (m - mid / a[i] + 1 >= 1)
      v[m - mid / a[i] + 1].push_back(i), c[i] = mid % a[i];
    else
      c[i] = mid - (long long)m * a[i];
  int cnt = 0;
  for (int i = m; i > 1; --i) {
    cnt += k;
    for (int jj = 0; jj < v[i].size(); ++jj) {
      int j = v[i][jj];
      assert(c[j] < a[j]);
      if (!cnt--) return 0;
      c[j] += p;
      if (i - c[j] / a[j] >= 1)
        v[i - c[j] / a[j]].push_back(j), c[j] %= a[j];
      else
        c[j] = c[j] - (i - 1ll) * a[j];
    }
  }
  cnt += k;
  for (int i = 1; i <= n; ++i)
    if (h[i] > c[i]) {
      if (cnt >= (h[i] - c[i] - 1) / p + 1)
        cnt -= (h[i] - c[i] - 1) / p + 1;
      else
        return 0;
    }
  assert(v[0].empty());
  return 1;
}
inline void work() {
  long long l = 0, r = 0;
  for (int i = 1; i <= n; ++i)
    smax(l, a[i]), smax(r, h[i] + (long long)m * a[i]);
  while (l < r) {
    long long mid = (l + r) >> 1;
    if (check(mid))
      r = mid;
    else
      l = mid + 1;
  }
  printf("%lld\n", l);
}
inline void init() {
  read(n), read(m), read(k), read(p);
  for (int i = 1; i <= n; ++i) read(h[i]), read(a[i]);
}
int main() {
  init();
  work();
  fclose(stdin), fclose(stdout);
  return 0;
}
