Earthquake

All submissions for this problem are available.
Read problems statements in Mandarin Chinese and Russian.
Earthquake in Bytetown! Situation is getting out of control!
All buildings in Bytetown stand on straight line. The buildings are numbered 0, 1, ..., N−1 from left to right.
Every hour one shake occurs. Each shake has 3 parameters: the leftmost building that was damaged during this shake, the corresponding rightmost building, and the force of the shake. Each time all the buildings in the disaster area are damaged equally. Let's consider this process in details.
At any moment every building has the number that indicates its height (may have leading zeroes). This number corresponds to some string consisting of digits. When some shake affects to the building its string circularly rotates to the left by the value of the force of the shake and its height corresponds to the value of new string. Pay attention that after rotation string may have leading zeroes. For instance: a building with height 950 got in disaster area with force 2, Then its string become 095, so height in reality is 95. If it was one more shake with force 1, then its height would become 950 again.
Major of Bytetown got some ideas how to protect residents, so sometimes he needs such kind of stats: find height of the highest building on some interval. You are given information about all the heights before the very first shake and then you get queries of two types:
 Type 0, described by 0 L_{i} R_{i} F_{i}: Shake occurred on interval [L_{i}, R_{i}] with force F_{i}.
 Type 1, described by 1 L_{i} R_{i}: The major wants to know the biggest height on interval [L_{i}, R_{i}].
Here, of course, the interval [L, R] contains all the building k such that L ≤ k ≤ R.
You want to get a promotion and promised to complete this task. Now it's time to do it!
Input
Each test file contains only one test case.
The first line of input contains an integer N denoting the number of buildings in Bytetown. The second line contains N spaceseparated integers A_{0}, A_{1}, ..., A_{N−1} denoting the initial height of the buildings. The third line contains an integer M denoting the number of queries. Each of next M lines starts with 0 or 1, where 0 denotes a query Type 0 and 1 denotes a Type 1 query. If it's a Type 0 query then 3 integers follows L_{i}, R_{i}, F_{i}, denoting number of the leftmost building, number of the rightmost building and force of this shake. If it's a Type 1 query then 2 integers follows L_{i}, R_{i}, denoting numbers of the leftmost building and the rightmost building of necessary segment.
Output
For each Type 1 query, output an integer denoting the answer for the query without leading zeroes.
Constraints
 1 ≤ N ≤ 800000 = 8 × 10^{5}
 1 ≤ M ≤ 200000 = 2 × 10^{5}
 0 ≤ A_{i} < 10000 = 10^{4}
 0 ≤ L_{i} ≤ R_{i} < N
 0 ≤ F_{i} ≤ 60
 A_{i} does not have leading zeroes
Example
Input: 3 17 3140 832 8 1 0 2 0 0 2 1 1 1 2 1 0 0 0 0 2 2 1 0 2 0 1 1 1 1 0 2 Output: 3140 1403 71 832 3140
Explanation
The initial array: [17, 3140, 832].
The first query is a Type 1 query with numbers of buildings 0 and 2, so the answer is the maximum of the array: 3140.
The second query is a Type 0 query with numbers of buildings 0 and 2, and force 1, so the array turns to: [71, 1403, 328].
The third query is a Type 1 query again with numbers of buildings 1 and 2, so the answer is the maximum of 1403 and 328: 1403
Author:  pavel1996 
Editorial  http://discuss.codechef.com/problems/EQUAKE 
Tags  aug14, lazy, medium, pavel1996, segmenttree 
Date Added:  27062014 
Time Limit:  2 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions