Hongjun Loves Painting

Bricks start with color equal to their index and colorfulness 0; range paint operations add the absolute color change to each brick, and queries ask for the total colorfulness over a range.

Hard8Segment treeImplementationMathDynamic programmingNo attempts yetTime limit2sMemory limit512 MB

Problem

Hongjun loves painting.

Hongjun got nn bricks as a birthday present and laid them out in a row. The leftmost brick is brick 1, the numbers grow by 1 toward the right, and the rightmost brick is brick nn. At the start, brick ii has color ii, and the colorfulness of every brick is 0.

Hongjun paints a contiguous range of bricks in one color. If brick ii currently has color yy and Hongjun paints it with color xx, the colorfulness of that brick grows by xy|x-y| and its color becomes xx.

Hongjun performs mm operations. Each operation is one of the following two.

  1. Paint bricks LL through RR with color XX.
  2. Compute the sum of colorfulness over bricks LL through RR.

Write a program that helps Hongjun.

Input

The first line contains the number of bricks nn and the number of operations mm. (1n,m1000001 \le n, m \le 100\,000)

Each of the next mm lines contains one operation. Every line starts with an integer TypeType (1 or 2) that gives the kind of operation.

If TypeType is 1, the integers LL, RR, XX of operation 1 follow. (1LRn1 \le L \le R \le n, 1X1000000001 \le X \le 100\,000\,000)

If TypeType is 2, the integers LL, RR of operation 2 follow. (1LRn1 \le L \le R \le n)

Output

Every time an operation of type 2 runs, print the sum of colorfulness over that range on one line, in the order the operations are given.