Solving CHANDQ with Persistent Segment Trees

https://discuss.codechef.com/questions/122105/chanoq-editorial
Can someone explain how to solve the problem with persistent segment trees, I have already tried with the Mo’s algorithm method.