#include <bits/stdc++.h>
using namespace std;
struct ff {
  long long x;
  int node;
} h1[100005], h2[100005];
int n, m, k, p, i, j, num, tmp, h[100005], a[100005];
long long l, r, ans, mid;
void up1(int x) {
  while (x > 1) {
    int i = x >> 1;
    if (h1[x].x / a[h1[x].node] < h1[i].x / a[h1[i].node])
      swap(h1[i], h1[x]), x = i;
    else
      return;
  }
}
void down1(int x) {
  while ((x << 1) <= num) {
    int i = x << 1;
    if (i < num && h1[i + 1].x / a[h1[i + 1].node] < h1[i].x / a[h1[i].node])
      i++;
    if (h1[x].x / a[h1[x].node] > h1[i].x / a[h1[i].node])
      swap(h1[i], h1[x]), x = i;
    else
      return;
  }
}
void up2(int x) {
  while (x > 1) {
    int i = x >> 1;
    if (h[h2[i].node] - h2[i].x < h[h2[x].node] - h2[x].x)
      swap(h2[i], h2[x]), x = i;
    else
      return;
  }
}
void down2(int x) {
  while ((x << 1) <= tmp) {
    int i = x << 1;
    if (i < tmp && h[h2[i + 1].node] - h2[i + 1].x > h[h2[i].node] - h2[i].x)
      i++;
    if (h[h2[i].node] - h2[i].x > h[h2[x].node] - h2[x].x)
      swap(h2[i], h2[x]), x = i;
    else
      return;
  }
}
int main() {
  scanf("%d%d%d%d", &n, &m, &k, &p);
  for (i = 1; i <= n; i++) scanf("%d%d", &h[i], &a[i]), l = max(l, 1ll * a[i]);
  r = 10000000000000ll;
  while (l <= r) {
    mid = (l + r) >> 1;
    num = tmp = 0;
    for (i = 1; i <= n; i++)
      if (mid - 1ll * a[i] * m < 0)
        h1[++num] = (ff){mid, i}, up1(num);
      else
        h2[++tmp] = (ff){mid - 1ll * a[i] * m, i}, up2(tmp);
    for (i = 1; i <= m; i++)
      for (j = 1; j <= k; j++)
        if (!num) {
          if (h2[1].x >= h[h2[1].node]) break;
          h2[1].x += 1ll * p, down2(1);
        } else {
          if (h1[1].x / a[h1[1].node] + 1 <= i) break;
          h1[1].x += 1ll * p;
          if (h1[1].x - 1ll * a[h1[1].node] * m >= 0) {
            h2[++tmp] = h1[1];
            h2[tmp].x -= 1ll * a[h1[1].node] * m;
            up2(tmp);
            swap(h1[1], h1[num--]);
          }
          down1(1);
        }
    if (num || h2[1].x < h[h2[1].node])
      l = mid + 1;
    else
      ans = mid, r = mid - 1;
  }
  printf("%lld\n", ans);
  return 0;
}
