This page is still under construction.

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

Pokemon GO

Time limit1sMemory limit32 MB

Summary
For each species, compute how many net 10-candy evolutions are possible, sum them, and find the species with the most evolutions.
Level

Easy2 of 10

Topics
Math, Implementation
Solved
No attempts yet

Problem

Pokemon GO

Ash started the mobile game Pokemon GO. In this game you can evolve your Pokemon.

Evolving a Pokemon PiP_i once costs KiK_i candies of that species. When the evolution finishes, 2 candies come back. A Pokemon evolves only with candies of its own species.

Ash has NN species, and he holds MiM_i candies of species PiP_i. The returned candies can be spent on the next evolution, so he keeps evolving the same species until the candies run short. For example, with Ki=12K_i = 12 and Mi=42M_i = 42 each evolution costs a net 10 candies, so he evolves 4 times: he evolves at 42, 32, 22 and 12 candies, and 2 candies are left at the end.

Find the total number of Pokemon Ash can evolve, and the name of the species he can evolve the most times. If several species tie, print the one with the smallest Pokedex number, that is, the one that appears earlier in the input. If not a single Pokemon can be evolved, print 0 and then the name of the species that appears first in the input.

Input

The first line contains the number of species NN (1≤N≤701 \le N \le 70).

The next 2N2N lines contain NN data sets.

  • Line 2i2i contains the name PiP_i of the ii-th Pokemon. Its length is at most 20.
  • Line 2i+12i + 1 contains the number of candies one evolution of the ii-th Pokemon costs, KiK_i (12≤Ki≤40012 \le K_i \le 400), and the number of candies of that species Ash holds, MiM_i (1≤Mi≤1041 \le M_i \le 10^4), separated by a space.

Output

On the first line, print the total number of Pokemon that can be evolved.

On the second line, print the name of the species that can be evolved the most times.

Examples2

  1. Example 1

    Input
    4
    Caterpie
    12 33
    Weedle
    12 42
    Pidgey
    12 47
    Rattata
    25 71
    
    Expected output
    14
    Weedle
    
  2. Example 2

    Input
    7
    Bulbasaur
    25 74
    Ivysaur
    100 83
    Charmander
    25 116
    Charmeleon
    100 32
    Squirtle
    25 1
    Wartortle
    100 173
    Pikachu
    50 154
    
    Expected output
    11
    Charmander