You are given a sequence A0,A1,…,AN−1 of length N. Every element satisfies 0≤Ai<232. Process the following four queries in the given order.
1 p v: insert v immediately before Ap. If p equals the current length of the sequence, append v at the end. (0≤p≤ length of the sequence, 0≤v<232)
2 p: remove Ap. (0≤p< length of the sequence)
3 p v: replace Ap with v. (0≤p< length of the sequence, 0≤v<232)
4 l r k: print (∑i=lrAi×(i−l+1)k)mod232. (0≤l≤r< length of the sequence, 0≤k≤10)
An insertion or a removal shifts the index of every element after it by one. The values p, l, and r in a query refer to the sequence as it stands when that query is processed.
The weight (i−l+1)k in query 4 is the position of Ai inside the range, counted from the left end starting at 1, raised to the power k.