Ishaan has been learning different representations of numbers, like binary, octal, decimal, etc. He has an assignment of a lot of problems. He is given 2 integers N and K.

Ishaan needs to convert N (given in decimal) and convert it to base K. Help him calculate the answer.

**Input : **

First line of input contains a single integer T denoting the number of test cases.

The only line of each test case contains 2 space-separated integers N and K.

**Output : **

For each test case, print the required answer in a new line.

**Constraints :**

1 <= T <= 200

1 <= N <= 10^9

2 <= K <= 10

**Example :
Input : **

3

10 2

4 8

15 6

1010

4

23

**Explanation :
Case 1 : **

10 in Binary = 1010

**Case 2 : **

4 in Octal = 4

**Case 3 : **

15 in Base 6 = 23

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 | 238 |

the_coder95 | 215 |

ShivayLamba | 208 |

sandeep.prajapati | 129 |

Ashish Kumar Vaishy | 114 |

the_coder95 | 1441 |

RishabhTanwar1 | 1110 |

thanuvinu94 | 914 |

tathagat289 | 668 |

themanhasnoname | 620 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4897 |

Quandray | 4547 |

Login to report an issue on this page.