Solved UVa 11777.