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 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 100,000 rubles in the decimal system.
Input
In the first line of the input file contains a number of prized employees (N < 50). Next to each staff member on a separate line in the gap indicates the age (<= 100) and premium in some base (record number does not contain insignificant zeros, using Arabic numerals and uppercase English letters).
Output
For each employee is displayed in a separate line one number - the size of awards in the decimal system.