solved POJ 3663