Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Sofdor Ali's Magical Blackboard!

By TarifEzaz · Limits 1s, 512 MB

Sofdor Ali found interest in mathematics very early in his life. And now, he wants to spread this interest to every young mind. But the way some of the Bangladeshi schools asks students to memorize the multiplication table disappoints him. “Multiplication is just repeated addition”, Sofdor says to himself and grieves as many young students do not even know this simple fact.

So he decided to open an online website for students named “Magical Blackboard” where they will be shown simple and yet important mathematical logics and puzzles. One of his lessons includes a puzzle where you will be given a number A, and you have to add it B times to get the sum. For example, if A = 2 and B = 3, then you need to add A 3 times and your answer should be ( 2 + 2 + 2 ) = 6.

Sofdor Ali has already decided about all the possible values for A and B which he will give to his online students. He asked for your help to write a program, that calculates the correct answer for every pair of A and B that Sofdor provides to you.


The first line contains an integer T ( 1 ≤ T ≤ 105 ), the number of test cases. The next T lines will contain a pair of A and B ( 1 ≤ A,B ≤ 109 ).

For 30 percent of the cases, both A and B will be less than or equal to 104.


For every pair of A and B, produce the correct result that Sofder expects from his students, on a line by itself.


2 3
10 10
4 5



92% Solution Ratio

zawad.abdullahEarliest, Jan '16

Anjum_AnjumFastest, 0.0s

oorpibLightest, 131 kB

touhidurShortest, 65B


Login to submit