Problem link : http://codeforces.com/problemset/problem/489/C

I’m pretty sure this one can be categorized as implementation. I simply create the largest number first, by using all the 9s on the first digits, then reverse the number to get the smallest one after substracting one from the rightmost non zero number in the largest number, and add it to the rightmost number in case if the rightmost number is zero.

There’s also a trap which I didn’t check… even if *m* is equal to zero it doesn’t always mean that there’s no answer (-1 -1)