My solution to POJ