#include <bits/stdc++.h>
using namespace std;
long long a[100010], h[100010];
int c[100010];
long long s[100010];
int n, m, k, p;
int check(long long x) {
  long long t = 0;
  for (int i = 1; i <= n; i = i + 1) t = t + max(0ll, (s[i] - x - 1 + p) / p);
  if (t > 1ll * m * k) return 1;
  for (int i = 1; i <= n; i = i + 1)
    if (s[i] > x) {
      for (long long j = (s[i] - x - 1) % p + 1; j <= s[i] - x; j = j + p) {
        if (h[i] >= j)
          c[0]++;
        else
          c[(j - h[i] + a[i] - 1) / a[i]]++;
      }
    }
  int ans = 0;
  for (int i = 0; i <= m - 1; i = i + 1) ans = max(0, c[i] - k + ans), c[i] = 0;
  return ans;
}
int main() {
  scanf("%d%d%d%d", &n, &m, &k, &p);
  for (int i = 1; i <= n; i = i + 1) scanf("%I64d%I64d", &h[i], &a[i]);
  long long l = 0, r = 0, mid;
  for (int i = 1; i <= n; i = i + 1) s[i] = a[i] * m + h[i];
  for (int i = 1; i <= n; i = i + 1)
    r = max(r, s[i]), l = max(l, (long long)a[i]);
  while (l < r) {
    mid = (l + r) >> 1;
    if (!check(mid))
      r = mid;
    else
      l = mid + 1;
  }
  printf("%I64d\n", l);
  return 0;
}
