Here is my accepted code : https://codeforces.net/contest/1791/submission/192106557
But this code should give TLE if the input is like :
1
200000 200000
a1 , a2 , a3 …… a200000
1 2 200000 (Update index 2 to 200000 and all 200000 queries are like this)