There are trees in Bob's back yard. The trees are numbered from
to
. Initially, the
-th tree's height is
, and the growth speed is
per day. Every day, the trees will grow in the morning. At night, Bob will adjust the height of trees by cutting them with his gardener scissors. For each cut, Bob will cut exactly
units of height from a tree if the tree's height is at least
. It's possible for a tree to reach the height
after a cut, but a tree cannot reach to the negative height. Bob can cut one tree multiple times in one day. In order not to get tired, Bob will cut at most
times each day.
Bob doesn't want his tree too tall. He wants to find the minimum possible height of the tallest tree after days. Can you write a program to help him?
Input Specification
The first line of input contains four integers ,
,
,
(
,
), indicating the number of trees, the number of days, the number of cuts in each day, and the length for each cut, respectively.
Each of the following lines contains two integers
and
, (
), indicating the initial height and the growth speed of the
-th tree.
Output Specification
Output one integer, the minimum possible height of the tallest tree after days.
Constraints
Subtask | Points | Additional constraints |
---|---|---|
No additional constraints. |
Sample Input
4 3 4 3
2 5
3 2
0 4
2 8
Sample Output
8
Explanation for Sample
- In day
, the trees initial height is
and the height after growing is
. Bob can cut the tree
once and tree
three times. Then the tree's final height is
.
- In day
, the trees initial height is
and the height after growing is
. Bob can cut the tree
twice and tree
twice. Then the tree's final height is
.
- In day
, the trees initial height is
and the height after growing is
. Bob can cut the tree
once, cut tree
twice and cut tree
once. Then the tree's final height is
.
Thus, the tallest tree's height is .
Comments