410061: GYM103934 I Offering to god Ra

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

I. Offering to god Ratime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Thiago is a poor farmer of the small village Khaldas, in ancient Egypt. Like it was common at that time, he needs to make an offering to Sun's god Rárada, also known as Ra. He needs to offer part of his harvest to show his gratefulness.

For this, Thiago will use baskets with capacity of $$$A$$$ grams of food. The total quantity of food must respect the following rules, as to not make Rá angry:

  1. All of the baskets must be full, so that Ra doesn't think Thiago is offering less food than he could
  2. Since Ra loves the number $$$B$$$, the total quantity of food (in grams) in decimal base must begin with the number $$$B$$$. For example, if $$$B=471$$$, the number $$$4715166$$$ accomplishes this rule, since $$$471$$$ is in its most significant digits.

Help Thiago to find some quantity of food (in grams) that he must offer to god Rá. Notice that this quantity must be less than $$$10^{18}$$$ that is the productive capacity of this poor farmer.

Input

The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) - the number of test cases. Then, $$$t$$$ lines follow.

Each line contains two space separated integers $$$A, B$$$ ($$$ 1 \leq A, B < 10^9$$$).

Output

For each test case, print only one integer, the answer for the problem.

ExampleInput
3
102 10
7 2
1000 3
Output
102
21
3000

Source/Category

加入题单

上一题 下一题 算法标签: