Given a number and its base, convert it to decimal. The base of number can be anything such that all digits can be represented using 0 to 9 and A to Z. Value of A is 10, value of B is 11 and so on.

**Input:**

The first line of input contains an integer T denoting the number of test cases. The first line of each test case is the base and second line of test case is the number which is to be converted to decimal.

**Output:**

Decimal conversion of the given number is displayed in the output.

**Constraints:**

1 <= T <= 5

2 <= base <=16

1 <= N <= decimal equivalents till 999999999

**Example:**

**Input:**

3

2

1100

16

11A

8

123

**Output:**

12

282

83

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

thanuvinu94 | 425 |

the_coder95 | 380 |

RishabhTanwar1 | 320 |

kunalk02141 | 306 |

RitikRosan | 272 |

the_coder95 | 1226 |

RishabhTanwar1 | 1040 |

tathagat289 | 636 |

thanuvinu94 | 634 |

themanhasnoname | 620 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4885 |

Quandray | 4547 |

Login to report an issue on this page.