ADATAXES  Ada and Taxes
As you might already know, Ada the Ladybug is a farmer. She grows vegetables in a long furrow. All of the vegetables have some height. Local politicians tax small vegetables, but as the furrow is very long, they always tax just a part of it.
The taxes always have some limit on height. They are calculated very simply: Tax collectors multiply the heights of all vegetables, which are lesser or equal to limit and are on desired segment.
The taxes might be very high so tax collectors just round their income and take only 1000000007 (10^{9}+7) banknotes. They are very kind, so they always leave the rest to Ada. She is interested in how much they will leave her.
NOTE: If none of the vegeteble is lesser/equal to given limit, Ada is left with symbolical 1 "money".
Input
The first line contains an integer 1 ≤ N, Q ≤ 3*10^{5}, the number of vegetables Ada grows and the number of times the tax collectors come.
The second line contains N integers 1 ≤ A_{i} ≤ 3*10^{5}, the heights of vegetables.
The next Q lines contains three integers 0 ≤ L ≤ R < N, the left and right vegetables of segment and 1≤ H ≤ 3*10^{5}, the limit.
Output
Print a single line for each query with the number of money Ada will be left with after each tax collecting.Example Input
10 6 1 2 3 4 5 10 9 8 7 6 5 5 5 0 2 3 0 9 9 4 8 8 2 4 11 2 2 3
Example Output
1 6 362880 280 60 3
hide comments
DOT:
20180823 19:07:54
Woah! Getting TLE with O(NlogN + QlogQ + Q√A) approach. Should try with segment tree, I guess.


yogahmad:
20170721 11:14:22
Last edit: 20170721 11:45:16 

morass:
20170629 14:38:03
@[Rampage] Blue.Mary: Sorry, seems I deleted part of input instead of harsh warning :'( is it better now? :O 

[Rampage] Blue.Mary:
20170629 12:20:14
The input specification doesn't match the sample input. 
Added by:  Morass 
Date:  20170629 
Time limit:  2s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All 