Sequence of points

CodeForces - 24C