#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
const long long INF = 1e15;
int n, m, k, p;
long long h[maxn], a[maxn];
long long sum[maxn], day[maxn];
bool check(long long x) {
  memset(day, 0, sizeof(day));
  int need = 0;
  for (int i = 1; i <= n; i++)
    if (sum[i] > x) {
      for (long long cur = (sum[i] - x) % p ? (sum[i] - x) % p : p;
           cur <= sum[i] - x; cur += p) {
        if (cur <= h[i])
          need = ++day[1];
        else if (cur - h[i] > a[i] * (m - 1))
          return false;
        else
          need = ++day[(cur - h[i] + a[i] - 1) / a[i] + 1];
        if (need > m * k) return false;
      }
    }
  need = 0;
  for (int i = 1; i <= m; i++) {
    need += day[i];
    need -= min(need, k);
  }
  return need == 0;
}
int main() {
  cin >> n >> m >> k >> p;
  for (int i = 1; i <= n; i++)
    scanf("%d%d", &h[i], &a[i]), sum[i] = h[i] + a[i] * m;
  long long L = 0, R = INF, mid;
  while (L + 1 < R) {
    mid = (L + R) / 2;
    if (check(mid))
      R = mid;
    else
      L = mid;
  }
  return 0 * printf("%I64d\n", R);
}
