Solved UVa 12502