The Millionaire's Will
Upon his passing, the millionaire left the following will for his children:
My dear children! I invested a fortune in your university education, and I hope it was worthwhile. I have divided my entire inheritance into 2 unequal parts. The smaller portion has been given to our lawyer to distribute equally among you. This amount should enable each of you to start your own business. The larger portion of the inheritance is secured in a bank vault with a password. The first one among you to determine the vault number and the password will inherit this money.
Below are two non-negative integers A and B. The password and the vault number are, respectively, the largest and smallest numbers for which the sum of the digits equals A, and the product of the digits equals B. Good luck!
Input
The first line contains two non-negative integers A and B, where A ≤ 10^5 and B ≤ 10^15.
Output
The first line should contain the vault number, and the second line should contain the password. If either value does not exist, output -1 instead.