SP5542 CPAIR - Counting pairs

Description

You're given a sequence A of N non-negative integers. Answer Q queries, where each query consists of three integers: v, a, b. The answer is number of pairs of integers i and j that satisfy these conditions: 1

Input Format

The first line of input contains two integers, N and Q. The second line contains the sequence A, consisting of N integers. Each of the next Q lines contains three numbers, v, a and b, defining a query.

Output Format

In the i-th line output only one integer denoting the answer to the i-th query.