problem1

Using python v 2.7.6
Testcase passed, results same as output2