Prize Hunter

Interview

Time limit1sMemory limit512 MB

Summary
Given two ranks a and b from two contests, print the total prize money using each contest's published prize table.
Level

Easy2 of 10

Topics
Implementation, Array
Solved
No attempts yet

Problem

After 2017, the Kakao Code Festival is held again in 2018.

Prizes are an inseparable part of the Kakao Code Festival. At the 1st Code Festival held in 2017, 21 of the 100 finalists received prizes according to the following rules.

RankPrizeWinners
1st5,000,000 won1
2nd3,000,000 won2
3rd2,000,000 won3
4th500,000 won4
5th300,000 won5
6th100,000 won6

At the 2nd Code Festival to be held in 2018, the prize pool is larger, and 31 of the 64 finalists will receive prizes according to the following rules.

RankPrizeWinners
1st5,120,000 won1
2nd2,560,000 won2
3rd1,280,000 won4
4th640,000 won8
5th320,000 won16

JY wonders how much prize money he would receive by competing in the Code Festival. To find out the total prize money he could earn across the finals of the two Code Festivals, he used his imagination and made the following assumptions.

  • He advanced to the finals of the 1st Code Festival and placed ath (1 ≤ a ≤ 100). If he did not advance, then a = 0.

  • He will advance to the finals of the 2nd Code Festival and place bth (1 ≤ b ≤ 64). If he does not advance, then b = 0.

Under these assumptions, JY wants to know the total prize money he can receive.

Input

The first line gives the number of assumptions T (1 ≤ T ≤ 1,000) that JY made using his imagination.

The next T lines give the information for each assumption JY made, one per line. Each line contains two non-negative integers a (0 ≤ a ≤ 100) and b (0 ≤ b ≤ 64), separated by a single space.

Output

For each assumption, print the prize money JY receives as an integer in won, one per line. The output must follow the order of the input.

Examples1

  1. Example 1

    Input
    6
    8 4
    13 19
    8 10
    18 18
    8 25
    13 16
    
    Expected output
    1780000
    620000
    1140000
    420000
    820000
    620000