Associated Course(s):
Geeks Classes in Noida
Geeks Classes in Noida- (Summer-Weekdays)

A boy lost the password of his super locker. He remembers the number of digits **N** as well as the sum **S** of all the digits of his password. He know that his password is the largest number of **N** digits that can be possible with given sum **S**. As he is busy doing his homework, help him retrieving his password.

**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 in password and **S** is the sum of all the digits of the password.

**Output:**

Corresponding to each test case, in a new line, print the largest integer if possible , else print -1.

**Constraints:**

1 <= T <= 100

1 <= N <= 10^{4}

0 <= S <= 10^{6}

**Example:**

**Input:**

3

5 12

3 29

3 26

**Output:**

93000

-1

998

**Explanation :**

**Testcase 1:** Sum of elements is 12. Largest possible 5 digit number is 93000.

**Testcase 2:** There is no such three digit number whose sum is 29.

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.

narahc321 | 170 |

agness | 163 |

lonecoder | 153 |

2016uec1342 | 142 |

HuHu | 140 |

lonecoder | 1088 |

nikhil_sojan | 1082 |

KshatriyaYash | 1066 |

mazumderrohit8 | 928 |

SumitSingh27 | 832 |

blackshadows | 5327 |

Ibrahim Nash | 5215 |

akhayrutdinov | 5111 |

mb1973 | 4504 |

Quandray | 4444 |

Login to report an issue on this page.