This page is still under construction.

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

Sim Card

Interview

Time limit2sMemory limit512 MB

Summary
For each student, compute the smallest total cost of call minutes and data across the three fixed operator price plans.
Level

Easy1 of 10

Topics
Implementation, Brute force, Math
Solved
No attempts yet

Problem

Iran has three mobile operators. Each operator charges a different price for calls and for data, as listed in the table below. All prices are in Rials.

#NameCall (per minute)Data (per megabyte)
1ParsTel3040
2ParsCell3530
3ParsPhone4020

Several foreign students came to Iran for a programming contest. Each student already knows how many minutes of calls and how many megabytes of data they will use. For each student, recommend the operator that makes the total of the call charge and the data charge as small as possible.

Input

Each line of the input holds the information of one student: two positive integers cc and dd (1≤c,d≤10001 \le c, d \le 1000), the call time in minutes and the data usage in megabytes. The input ends with a line 0 0, which you do not process.

Output

For each student, print the minimum total of the call charge and the data charge on its own line, in input order.

Examples2

  1. Example 1

    Input
    10 60
    100 20
    24 12
    900 400
    50 50
    0 0
    
    Expected output
    1600
    3800
    1200
    43000
    3000
    
  2. Example 2

    Input
    1 1
    0 0
    
    Expected output
    60