UVa 12906: Accepted version