Under construction

Still being built. Things may change

Roulette

Time limit1sMemory limit1024 MB

Summary
Albums cost A_i won for B_i tickets each, and each re-spin costs R won; find the minimum expected cost to guarantee a win as a reduced fraction.
Level

Medium7 of 10

Topics
Dynamic programming, Probability, Math
Solved
No attempts yet

Problem

You are a big fan of Korea's biggest rockstar, Koosaga. Koosaga has announced a lottery event offering fans a once-in-a-lifetime chance at a one-on-one meeting.

Koosaga sells NN kinds of albums. When you buy the ii-th album, it costs AiA_i won and gives you BiB_i lottery tickets. You can buy multiple copies of the same album.

On the day of the draw, a large roulette wheel with cells containing participant names decides the winner. Every cell has an equal chance of being selected. The number of cells with your name equals the number of lottery tickets you hold.

Koosaga spins the wheel once to pick the winner. By paying RR won, you can ask Koosaga to spin the wheel again. You can pay for as many re-spins as you want.

The total number of cells belonging to other participants is SS. None of them requests a re-spin. Only you request re-spins, when you want to.

Find the strategy that guarantees your win with the minimum expected cost.

Input

The first line contains three space-separated integers NN, SS, RR.

The next NN lines each contain two space-separated integers. The ii-th line contains AiA_i and BiB_i.

Output

Print a single line containing two space-separated positive integers XX, YY. XY\frac{X}{Y} must be the minimum expected cost to win, and XX and YY must be coprime. It can be proven that the minimum expected cost can be written in this form.

Constraints

  • 1≤N≤1000001\le N\le 100000
  • 1≤S≤1061\le S\le 10^6
  • 1≤R≤1061\le R\le 10^6
  • 1≤Ai≤3001\le A_i\le 300 (1≤i≤N1\le i\le N)
  • 1≤Bi≤50001\le B_i\le 5000 (1≤i≤N1\le i\le N)

Examples1

  1. Example 1

    Input
    3 11 3
    1 3
    2 7
    5 13
    
    Expected output
    63 10