contest 460, problem C backsolved