#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int N = 1e5 + 100;
long long n, m, k, p, h[N], a[N];
struct Node {
  int id;
  long long day, cnt;
  Node() {}
  Node(int id, long long day, long long cnt) : id(id), day(day), cnt(cnt) {}
  bool operator<(const Node& t) const { return day > t.day; }
};
bool check(long long mid) {
  priority_queue<Node> q;
  for (int i = 1; i <= n; i++)
    if (mid - h[i] < m * a[i]) q.push(Node(i, mid / a[i], 0));
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= k; j++) {
      if (q.empty()) return true;
      Node cur = q.top();
      q.pop();
      if (cur.day < i) return false;
      cur.cnt++;
      if (mid - h[cur.id] < m * a[cur.id] - cur.cnt * p)
        q.push(Node(cur.id, (mid + cur.cnt * p) / a[cur.id], cur.cnt));
    }
  }
  return q.empty();
}
int main() {
  scanf("%lld%lld%lld%lld", &n, &m, &k, &p);
  for (int i = 1; i <= n; i++) scanf("%lld%lld", h + i, a + i);
  long long l = 0, r = 1e13, ans = -1;
  while (l <= r) {
    long long mid = l + r >> 1;
    if (check(mid)) {
      ans = mid;
      r = mid - 1;
    } else
      l = mid + 1;
  }
  printf("%lld\n", ans);
  return 0;
}
