first solution to UVA 10810