Close #9. Solve POJ 1008