This page is still under construction.

Parts of this page are still being built. What you see may change.

Carousel Rides

Time limit1sMemory limit1024 MB

Summary
For each test case, pick the offer with the lowest price per ticket among those buying at most m tickets, breaking ties toward the offer that buys more tickets.
Level

Easy2 of 10

Topics
Implementation, Brute force
Solved
No attempts yet

Problem

Carl likes to ride the carousel. Carousel operators often offer discounts for buying multiple rides. He wonders which of the discounts provides the best value.

Write a program to help him.

Input

The input contains multiple test cases. A test case starts with a line containing two numbers nn (1≤n≤101 \le n \le 10) and mm (1≤m≤201 \le m \le 20). Carl does not take offers that require him to buy more than mm tickets. Next come nn lines, each with two numbers aa and bb, meaning an offer to buy aa tickets for $b. The input ends with a line containing 0 0.

Output

For each test case, print Buy a tickets for \$b for the best offer that Carl can use. If several offers tie, print the one that buys more tickets. If no offer is suitable, print No suitable tickets offered.

Examples1

  1. Example 1

    Input
    3 5
    1 3
    3 5
    4 7
    3 2
    3 5
    1 3
    4 7
    3 2
    3 6
    1 2
    2 4
    1 3
    4 10
    0 0
    
    Expected output
    Buy 3 tickets for $5
    Buy 1 tickets for $3
    Buy 2 tickets for $4
    No suitable tickets offered