#include <bits/stdc++.h>
const int MAXN = 1e5 + 5;
long long h[MAXN], a[MAXN], t[MAXN];
int n, m, k, p;
int main() {
  scanf("%d%d%d%d", &n, &m, &k, &p);
  for (int i = 1; i <= n; ++i) scanf("%lld%lld", h + i, a + i);
  long long l = 0, r = 1e13, ans = -1;
  while (l <= r) {
    long long mid = (l + r) >> 1;
    auto chk = [&]() {
      std::priority_queue<std::pair<long long, int>,
                          std::vector<std::pair<long long, int> >,
                          std::greater<std::pair<long long, int> > >
          q;
      for (int i = 1; i <= n; ++i) t[i] = mid;
      for (int i = 1; i <= n; ++i)
        if (t[i] / a[i] < m) q.push(std::make_pair(t[i] / a[i], i));
      int cnt = m * k;
      for (int i = 1; i <= m; ++i) {
        if (!q.empty() && q.top().first < i) return false;
        int tmp = k;
        while (tmp && !q.empty()) {
          std::pair<long long, int> v = q.top();
          q.pop();
          t[v.second] += p;
          if (t[v.second] / a[v.second] < m)
            q.push(std::make_pair(t[v.second] / a[v.second], v.second));
          --tmp;
        }
        cnt -= k - tmp;
        if (q.empty()) break;
      }
      long long r = 0;
      for (int i = 1; i <= n; ++i) t[i] -= m * a[i];
      for (int i = 1; i <= n; ++i)
        if (t[i] < h[i]) r += (h[i] - t[i] + p - 1) / p;
      return r <= cnt;
    };
    if (chk())
      ans = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  printf("%lld\n", ans);
  return 0;
}
