Solved UVa 572