Solved POJ 2817