#include <bits/stdc++.h>
using namespace std;
long long h[100005], zeng[100005], tot[100005], _cnt[100005];
int m, n, k, p;
bool judge(long long x) {
  long long cnt = 0;
  int i, j;
  memset(_cnt, 0, sizeof(_cnt));
  for (i = 1; i <= n; i++)
    if (tot[i] > x) cnt += (tot[i] - x - 1) / p + 1;
  if (cnt > k * m) return false;
  for (i = 1; i <= n; i++)
    if (tot[i] > x) {
      for (j = (tot[i] - x - 1) % p + 1; j <= tot[i] - x; j += p)
        _cnt[j <= h[i] ? 0 : (j - h[i] - 1) / zeng[i] + 1]++;
    }
  if (_cnt[m]) return false;
  for (i = 0, cnt = 0; i < m; i++) cnt = max((long long)0, cnt + _cnt[i] - k);
  return cnt == 0;
}
int main() {
  int i;
  long long l = 0, r = 0, mid;
  scanf("%d%d%d%d", &n, &m, &k, &p);
  for (i = 1; i <= n; i++) {
    scanf("%I64d%I64d", &h[i], &zeng[i]);
    tot[i] = h[i] + zeng[i] * m;
    r = max(r, tot[i]);
  }
  while (r > l + 1) {
    mid = (l + r) >> 1;
    if (judge(mid))
      r = mid;
    else
      l = mid;
  }
  printf("%I64d\n", r);
}
