#include <bits/stdc++.h>
using namespace std;
const int P = 1e9 + 7;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long qpow(long long a, long long n) {
  long long r = 1 % P;
  for (a %= P; n; a = a * a % P, n >>= 1)
    if (n & 1) r = r * a % P;
  return r;
}
long long inv(long long x) { return x <= 1 ? 1 : inv(P % x) * (P - P / x) % P; }
const int N = 2e5 + 10;
int a[N], h[N], f[N], n, m, k, p;
struct _ {
  long long day, id;
  bool operator<(const _& rhs) const { return day > rhs.day; }
};
priority_queue<_> q;
bool check(long long x) {
  memset(f, 0, sizeof f);
  while (!q.empty()) q.pop();
  for (int i = 1; i <= n; ++i)
    if (x - (long long)a[i] * m < h[i]) q.push({x / a[i], i});
  for (int i = 1; i <= m; ++i)
    for (int j = 1; j <= k; ++j) {
      if (q.empty()) return 1;
      _ u = q.top();
      q.pop();
      if (u.day < i) return 0;
      if (x + (long long)p * ++f[u.id] - (long long)m * a[u.id] < h[u.id]) {
        q.push({(x + (long long)p * f[u.id]) / a[u.id], u.id});
      }
    }
  return q.empty();
}
int main() {
  scanf("%d%d%d%d", &n, &m, &k, &p);
  for (int i = 1; i <= n; ++i) scanf("%d%d", h + i, a + i);
  long long l = 0, r = 1e15, ans;
  while (l <= r)
    check((l + r >> 1))                        ? ans = (l + r >> 1),
                          r = (l + r >> 1) - 1 : l = (l + r >> 1) + 1;
  cout << ans << endl;
}
