#P10288. Frequency Query

    ID: 12288 Type: Default 1000ms 256MiB

Frequency Query

Frequency Query

You are given a positive integer sequence AA of length nn.

There are qq queries. In the ii-th query (1iq1 \le i \le q), you are given three integers lil_i, rir_i, and xix_i. You need to determine the number of times xix_i appears in the subarray Ali,Ali+1,,AriA_{l_i}, A_{l_i+1}, \dots, A_{r_i}.

inputFormat

The first line contains two integers nn and qq.

The second line contains nn positive integers representing the sequence AA.

Each of the following qq lines contains three integers lil_i, rir_i, xix_i describing a query.

outputFormat

For each query, output one integer — the number of occurrences of xix_i in the subarray Ali,Ali+1,,AriA_{l_i}, A_{l_i+1}, \dots, A_{r_i}.

sample

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

1 1

</p>