Zero health with minimum mana

Each use of a skill costs more than its previous use by K; find the minimum total mana to remove exactly M health.

Medium7Dynamic programmingMathGreedyNo attempts yetTime limit1sMemory limit128 MB

Problem

Gwanghyeon plays a game called League of Storms. You win by using skills to drop the opponent's health to 0 or below, but Gwanghyeon set his own restriction: bring the health to exactly 0 while spending as little mana as possible.

There are NN skills. Using skill ii once spends XiX_i mana and removes YiY_i health from the opponent. A skill can be used any number of times, but every repeat of the same skill costs KK more mana than the previous use of that skill. For example, a skill with a cost of 10 and K=5K = 5 spends 10 on the first use, 15 on the second, and 20 on the third. The increase is counted separately for each skill, and the order of the uses does not change the total.

The opponent's health is MM. Find the smallest amount of mana needed to bring it to exactly 0.

Input

The first line contains the number of skills NN, the enemy's health MM, and the extra mana KK added on each repeat of the same skill. (1N,M,K1001 \le N, M, K \le 100)

Each of the next NN lines describes one skill with the mana it needs, XX, and the health it removes, YY. (1X,Y1001 \le X, Y \le 100)

Every input has at least one combination that brings the enemy's health to exactly 0.

Output

Print on the first line the smallest amount of mana needed to bring the enemy's health to exactly 0.