#include <bits/stdc++.h>
using namespace std;
const int maxN = 100005, maxM = 5003;
int n, m, k, p;
long long h[maxN], a[maxN], maxH[maxN];
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cin >> n >> m >> k >> p;
  for (int i = 0; i < n; i++) {
    cin >> h[i] >> a[i];
    maxH[i] = h[i] + a[i] * m;
  }
  long long l = 0, r = 2e13;
  while (l < r - 1) {
    long long mid = (l + r) / 2;
    bool flag = true;
    long long tot = 0;
    for (int i = 0; i < n; i++) tot += max(0LL, (maxH[i] - mid + p - 1) / p);
    if (tot > m * k)
      flag = false;
    else {
      int t[maxM] = {};
      for (int i = 0; i < n; i++)
        if (maxH[i] > mid) {
          for (long long target = (maxH[i] - mid) % p == 0 ? p : maxH[i] - mid;
               target <= maxH[i] - mid; target += p)
            if (target - h[i] <= 0)
              t[0]++;
            else if (target - h[i] > a[i] * (m - 1)) {
              flag = false;
              goto endLoop;
            } else {
              t[(target - h[i] + a[i] - 1) / a[i]]++;
            }
        }
      int rest = 0;
      for (int i = 0; i < m; i++) rest = max(0, rest + t[i] - k);
      flag = rest == 0;
    }
  endLoop:
    (flag ? r : l) = mid;
  }
  cout << r << endl;
  return 0;
}
