#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  long long r;
  while (b != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
const int maxn = 100010;
const int maxm = 5010;
int n, m, k;
long long p;
long long h[maxn];
long long a[maxn];
long long b[maxn];
int t[maxm];
bool check(long long mid) {
  long long tot = 0;
  for (int i = 0; i < n; i++)
    if (b[i] > mid) tot += max(0LL, (b[i] - mid + p - 1) / p);
  if (tot > m * k) return false;
  memset(t, 0, sizeof(t));
  for (int i = 0; i < n; i++) {
    long long end = b[i] - mid - h[i];
    for (long long j = end; j + h[i] > 0; j -= p) {
      if (j <= 0)
        t[0]++;
      else if (j > a[i] * (m - 1))
        return false;
      else
        t[(j + a[i] - 1) / a[i]]++;
    }
  }
  int tmp = 0;
  for (int i = 0; i < m; i++) {
    tmp += t[i];
    tmp = max(0, tmp - k);
  }
  return tmp == 0;
}
void solve() {
  scanf("%d%d%d%I64d", &n, &m, &k, &p);
  for (int i = 0; i < n; i++) scanf("%I64d%I64d", h + i, a + i);
  for (int i = 0; i < n; i++) b[i] = h[i] + a[i] * m;
  long long l = 0, r = 1e18;
  while (l < r) {
    long long mid = (l + r) >> 1;
    if (!check(mid))
      l = mid + 1;
    else
      r = mid;
  }
  printf("%I64d", l);
}
int main() {
  solve();
  return 0;
}
