#include <bits/stdc++.h>
template <typename T>
inline void relax(T &a, T b) {
  if (a < b) a = b;
}
inline unsigned int getuint() {
  char w = getchar();
  while (w < '0' || '9' < w) w = getchar();
  unsigned int ans = 0;
  for (; '0' <= w && w <= '9'; w = getchar()) ans = ans * 10 + w - '0';
  return ans;
}
int n, m, k;
unsigned long long p;
const int MAXN = 100005;
unsigned long long a[MAXN], d[MAXN], Final[MAXN];
int cnt[MAXN];
bool check(unsigned long long tar) {
  unsigned long long tot = 0;
  for (int i = 1; i <= n; i++)
    if (Final[i] > tar) tot += (Final[i] - tar - 1) / p + 1;
  if (tot > m * k) return false;
  memset(cnt + 1, 0, m * sizeof(int));
  for (int i = 1; i <= n; i++)
    if (Final[i] > tar)
      for (unsigned long long now = (Final[i] - tar - 1) % p + 1;
           now <= Final[i] - tar; now += p)
        if (now <= a[i])
          cnt[1]++;
        else if (now - a[i] > d[i] * (m - 1))
          return false;
        else
          cnt[(now - a[i] - 1) / d[i] + 2]++;
  int rest = 0;
  for (int i = 1; i <= m; i++) rest = std::max(0, rest + cnt[i] - k);
  return !rest;
}
int main() {
  n = getuint(), m = getuint(), k = getuint(), p = getuint();
  unsigned long long l = 0, r = 0;
  for (int i = 1; i <= n; i++)
    a[i] = getuint(), relax(r, Final[i] = a[i] + (d[i] = getuint()) * m);
  while (r - l > 1) {
    unsigned long long mid = (l + r) >> 1;
    if (check(mid))
      r = mid;
    else
      l = mid;
  }
  printf("%I64u\n", r);
  return 0;
}
