poj problem 1806