Solved UVa 1124.