Solved UVa 12468.
Solved UVa 12157.