Help needed in a segment tree problem

problem Link
Editorial Link

I tried to solve it using basic segment tree.But I have no idea why is it giving TLE.According to me the complexity is QLOGN . For each query of type 2 I made one call which is of order LogN and qry 1 ,3 calls which are also of O(LOGN). Can anyone please tell me where did I messed up?
My Submission