3412. Swaps and Sum

单测试点时限: 2.0 秒

内存限制: 256 MB

You are given a sequence . The task is to perform the following queries on it:

  • Type 1. Given two integers and . Reorder the elements of the sequence in such a way (changed part of the sequence is in brackets):

    That is swap the first two elements of segment , the second two elements, and so on.

  • Type 2. Given two integers and , print the value of sum .

输入

The first line contains two integers and . The second line contains integers , denoting initial sequence.

Each of the next lines contains three integers , where denotes the type of the query, and are parameters of the query. It’s guaranteed that for a first-type query will be even.

输出

For each query of the second type print the required sum.

样例

Input
6 4
1 2 3 4 5 6
1 2 5
2 2 3
2 3 4
2 4 5
Output
5
7
9

1 人解决,2 已尝试。

1 份提交通过,共有 2 份提交。

9.9 EMB 奖励。

创建: 1 年,3 月前.

修改: 1 年,3 月前.

最后提交: 1 年,2 月前.

来源: HackerRank