#SGM0000070. Super Mario (Super Mario)

Super Mario (Super Mario)

Super Mario (Super Mario)

Source: HDU

Version: Phuoc Hung OJ Extended

Problem

There are nn bricks at positions 0..n−10..n-1, with height hih_i. For each query L,R,HL,R,H, count positions in [L,R][L,R] whose height is at most HH.

Input

The first line contains n,mn,m, the second line contains the heights, and each next line contains L,R,HL,R,H.

Output

Print the number of bricks with height at most HH for every query.

Subtasks

Subtask 1 (20%)

  • n≤30n\le 30, number of queries ≤30\le 30.
  • All other conditions are the same as Subtask 3.

Subtask 2 (30%)

  • n≤3000n\le 3000, number of queries ≤3000\le 3000.
  • All other conditions are the same as Subtask 3.

Subtask 3 (50%)

  • 1≤n,m≤1051\le n,m\le10^5
  • 0≤hi,H≤1090\le h_i,H\le10^9
  • 0≤L≤R<n0\le L\le R<n
  • indexing is 0-based

Example

Input

10 10
0 5 2 7 5 4 3 8 7 7
2 8 6
3 5 0
1 3 1
1 9 4
0 1 0
3 5 5
5 5 1
4 6 3
1 5 7
5 7 3

Output

4
0
0
3
1
2
0
1
5
1

Explanation

For the first query, the heights at positions 2..82..8 are [2,7,5,4,3,8,7]; four are at most 66.