Processing math: 100%
Count query - MarisaOJ: Marisa Online Judge

Count query

Time limit: 1000 ms
Memory limit: 256 MB

You are given:

  • An array A of n positive integers.
  • q queries of form (l,r,x), count the occurences of x in subarrary Al,Al+1,…,Ar.

Input

  • The first line contains 2 integer n,q.
  • The second line contains n space-separated integers Ai.
  • The next q lines, each line contains 3 space-separated integers l,r,k.

Output

  • Print q lines, ith line is an integer, the answer to query i.

Constraints

  • 1≤n,q,k,Ai≤105.
  • 1≤l≤r≤n.

Example

Input:

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

Output:

2
3
1