Interval tree can be regarded as an extension of traditional segment tree: each vertex in interval tree still represents a interval, but the split points do not need to be the middle point.
For example, the following picture describe an interval tree on [1,6]:
Similar with segment tree, we can do some interval queries on interval tree. And we can define the time complexity of interval [l,r] as the number of vertices we need to visit when the query is about [l,r].
Formally, let S[l,r] be the set of vertices v on the interval tree which satisfy one of the following 2 conditions:
(1) v's interval is a subinterval of [l,r], but vv's father's interval is not.
(2) At least one of v's decendants satisfies (1).
And then, we can define the time complexity of [l,r] as the size of S[l,r].
For example, in the picture, all the vertices in S[2,4] has been marked as blue. So the time complexity of [2,4] in this interval tree is 66.
Now, given an interval tree on [1,n] and have q queries. Each query is a positive integer k, you need to find out the number of different intervals of which the time complexity is exactly k.