UVA 3nplus1 problem accepted