modify uva10716, poj1854