问题 4345 --(2008珠海赛) Discount

4345: (2008珠海赛) Discount

时间限制: 1 Sec  内存限制: 256 MB
提交: 0  解决: 0
[提交][状态][讨论版][命题人:]

题目描述

People like to buy gifts in discount. For example, gift A with initial price RMB50, 30% off actually costs RMB35, gift B with initial price RMB104, 17% off actually costs RMB86.32. Mr.Richman is a rich man. He hates small money, so he always pays an integer number of RMBs without getting any change. What’s more, being a traditional Chinese person, the amount of money he pays always contains the lucky digit ’8’ (of course, the integer MUST be at least the actual price after discount). For example, he would pay RMB38 for gift A, and RMB87 for gift B. Given the initial price and the discount for a gift, calculate how much Mr.Richman would like to pay.

输入

The first line contains t (1 ≤ t ≤ 20), the number of test cases followed. Each line contains two integers P and D(1 ≤ P ≤ 500, 1 ≤ D ≤ 99), the initial price and discount.

输出

For each test case, print the amount of money Mr.Richman would like to pay.

样例输入

5
50 30
104 17
500 4
498 6
40 5

样例输出

38
87
480
478
38

来源

[提交][状态]