solution for UVA 482