Hey Community

I was practicing questions on segment tree and I come across this question ,

link

http://www.spoj.com/problems/IOPC1207/

I know that i need to make 3 segment tree here each for every coordinate but i am unable to proceed further . I have checked out some github solutions as well but unable to understand . If anyone can tell the algorithm it will be highly appreciated . Also this is a very interesting question so all those who love fancy problem statements this is your type of question . Thanks in Advance