Wrapped solution into print function and formatted the output to be more pretty.