sulution for POJ 1001