#include <bits/stdc++.h>
using namespace std;
long long cnt[5010];
long long H[101000], A[101000];
int n, m;
long long k, p, L, R;
long long Div(long long a, long long b) { return ((a + b - 1LL) / b); }
bool judge(long long mid) {
  long long res = 0;
  for (int i = 1; i <= n; i++) res += Div(max(H[i] + A[i] * m - mid, 0LL), p);
  if (res > m * k) return false;
  memset(cnt, 0, sizeof(cnt));
  for (int i = 1; i <= n; i++) {
    if (H[i] + A[i] * m <= mid) continue;
    long long tar = (H[i] + A[i] * m - mid) % p;
    if (!tar) tar += p;
    for (; tar + mid <= H[i] + A[i] * m; tar += p) {
      int sing;
      if ((sing = Div(max(tar - H[i], 0LL), A[i])) > m - 1) return false;
      if (tar <= H[i])
        cnt[1]++;
      else
        cnt[sing + 1]++;
    }
  }
  for (int i = 1; i <= m; i++) {
    cnt[i] = max(0LL, cnt[i] - k);
    cnt[i + 1] += cnt[i];
  }
  return (cnt[m + 1] == 0LL);
}
int main() {
  cin >> n >> m >> k >> p;
  for (int i = 1; i <= n; i++) {
    scanf("%lld %lld", &H[i], &A[i]);
    R = max(R, H[i] + A[i] * m);
  }
  while (L < R) {
    long long mid = (L + R) >> 1;
    if (judge(mid))
      R = mid;
    else
      L = mid + 1LL;
  }
  cout << L << endl;
  return 0;
}
