Little Elephant and Problem

CodeForces - 221C