Associated Course(s):
Must Do Interview Preparation

Given two numbers '**N**' and '**S**' , find the **largest number** that can be formed with '**N**' digits and whose sum of digits should be equals to '**S**'.

**Input**

The first line of input contains an integer **T** denoting the number of test cases. Then **T** test cases follow. The first line of each test case contains two space separated integers **N** and **S**, where **N** is the number of digits and **S** is the sum.

**Output**

Print the **largest number** that is possible.

If their is no such number, then print -1

**Constraints:**

1 <= **T** <= 30

1 <= **N** <= 50

0 <= **S** <= 500

**Example **

**Input**

2

2 9

3 20

**Output **

90

992

**Expected Time Complexity: **O(n)

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.

the_coder95 | 465 |

thanuvinu94 | 388 |

adityasuman2025 | 348 |

Senbonzakura_Kageyoshi | 321 |

PrakharBansal1 | 294 |

the_coder95 | 1691 |

RishabhTanwar1 | 1110 |

thanuvinu94 | 1064 |

samay_kam_hai | 726 |

adityasuman2025 | 646 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4897 |

Quandray | 4547 |

Login to report an issue on this page.