A Taste of Queries

Given a sequence of n numbers, process q queries that either report a range sum and then swap two positions, or report one range sum minus another.

Medium4ArrayPrefix sumImplementationSimulationInterviewNo attempts yetTime limit2sMemory limit256 MB

Problem

A problem that asks several questions of the same shape is called a query problem. You can answer the queries in the order they are given, and when that is impossible or when the conditions allow it, you can also reorder the queries freely and answer them more comfortably.

Here you are given a sequence of length nn and qq queries. There are two kinds of queries.

  • 1 a b: print the sum of the range [a,b][a, b], then swap the aa-th number and the bb-th number of the sequence.
  • 2 a b c d: print the sum of the range [a,b][a, b] minus the sum of the range [c,d][c, d].

The sum of the range [a,b][a, b] is the total of the aa-th through bb-th numbers of the sequence. A type 1 query modifies the sequence, so process the queries in the order they are given.

Input

The first line contains the length of the sequence nn (1n10001 \le n \le 1000) and the number of queries qq (1q100001 \le q \le 10000).

The second line contains the nn numbers of the sequence, separated by single spaces. Each number is an integer between 2147483648-2147483648 and 21474836472147483647, inclusive.

Each of the next qq lines contains one query, in the form 1 a b or 2 a b c d. The values aa, bb, cc, dd are positive integers not greater than nn, and aba \le b and cdc \le d are guaranteed.

Output

Print the answer to each query on its own line, in the order the queries are given, for a total of qq lines.