PLEASE HELP

SOLUTION LINK :https://www.codechef.com/viewsolution/26231271
PROBLEM LINK: https://www.codechef.com/problems/COKE2
I have implemented the same approach as mentioned in the editorial. I have created a segment tree for storing minimum’s for all segments of 1 to Q. I am not using Lazy Propagation here. I have created three functions : buildTree(), updatetree() and printquery(). Please can anyone tell me why my code is giving WA. It is working fine for sample testcases. Please provide a test case that my code might be failing. PLEASE HELP