Given an array of $n$ integers, you have to process following operations:
reverse a subarraycalculate the sum of values in a subarray
The first input line has two integers $n$ and $m$ : the size of the array and the number of operations. The array elements are numbered $1,2,\dots,n$ .
The next line as $n$ integers $x_1,x_2,\dots,x_n$ : the contents of the array.
Finally, there are $m$ lines that describe the operations. Each line has three integers $t$ , $a$ and $b$ . If $t=1$ , you should reverse a subarray from $a$ to $b$ . If $t=2$ , you should calculate the sum of values from $a$ to $b$ .
Print the answer to each operation where $t=2$ .
8 3 2 1 3 4 5 3 4 4 2 2 4 1 3 6 2 2 4
· \n · · · · · · · \n · · \n · · \n · · \n
8 9
\n \n