#ds102. 树状数组2

树状数组2

Fenwick Tree 2

Problem Description

There are nn numbers a1,a2,a3,…,ana_1, a_2, a_3, \dots, a_n, all initially 00.

You must support qq operations:

  1. 1 l r d: add dd to every aia_i with l≤i≤rl \le i \le r.
  2. 2 x: output (∑i=1xai) mod 264\left(\sum_{i=1}^{x} a_i\right) \bmod 2^{64}.

Input Format

The first line contains two integers nn and qq (1≤n,q≤2×1051 \le n, q \le 2 \times 10^5).

The following qq lines each describe an operation of the form 1 l r d or 2 x, with 1≤x≤n1 \le x \le n, 1≤d≤1091 \le d \le 10^9, and 1≤l≤r≤n1 \le l \le r \le n.

Output Format

For each query, output one line containing the answer.

Sample Input

5 5
1 2 3 1
1 1 5 2
2 4
1 1 3 3
2 5

Sample Output

10
21

Constraints

1≤n,q≤2×1051 \le n, q \le 2 \times 10^5, 1≤d≤1091 \le d \le 10^9, 1≤x≤n1 \le x \le n, 1≤l≤r≤n1 \le l \le r \le n.