- Time limit: 1.50 s
- Memory limit: 512 MB
Maija works at a software company that sells its customers' information to other companies on demand. The company's database contains information about the customers' interests and is sorted by their age, from youngest to oldest. The database is flooded with the following type of queries: How many people between the ages are interested in thing ? It can no longer keep up with the queries and Maija is tasked to write some specialized software to solve this issue.
The database contains people numbered and things people are interested in. The -th youngest person is interested in thing . There are also pre-processed queries of the form: - how many people between the -th youngest and -th youngest (inclusive) are interested in thing x?
Input
The first line contains three integers ,, and . The second line contains integers . The -th of the next lines contains three integers , , and .
Output
Print the answers to the queries, each on their own line.
Constraints
Example 1
Input:
5 5 5 3 1 5 5 4 1 3 1 2 4 4 3 4 5 1 5 3 3 4 1
Output:
1 0 2 1 0
Example 2
Input:
10 2 9 1 2 2 2 1 1 1 1 1 1 3 7 2 2 3 1 3 7 2 6 9 2 2 5 2 2 6 2 3 8 2 5 6 1 2 9 1
Output:
2 0 2 0 3 3 2 2 5