eolymp
bolt
Try our new interface for solving problems

Award

Director of the company decided to pay employees bonuses. The next day was released a list of the lucky ones. In order not to disclose the size of payments in the list against the names emblazoned with strange numbers and even letters. The staff quickly realized that the amount of premiums written in different number systems. But where and what number system is used, realized only secretary Tanya, who remembered that the director asked her to bring information about the age of employees. She realized that the director cast dozens of numbers indicating the age and the remaining units, added the number \textbf{2}. This value served as the basis for the submission of assessed premiums. Help Tanya curious to know the size of awards in the decimal system. It is known that the premium does not exceed \textbf{100,000} rubles in the decimal system. \InputFile In the first line of the input file contains a number of prized employees (\textbf{N} < \textbf{50}). Next to each staff member on a separate line in the gap indicates the age (<= \textbf{100}) and premium in some base (record number does not contain insignificant zeros, using Arabic numerals and uppercase English letters). \OutputFile For each employee is displayed in a separate line one number - the size of awards in the decimal system.
Time limit 1 second
Memory limit 64 MiB
Input example #1
2
28 2800
30 101
Output example #1
2800
5
Source Школа Программиста, Красноярский край, Пятая командная олимпиада, 15 ноября 2009, Задача A