You are given the following:
For every number c in range [1:m], you know its happiness is hc. A subarray is called happy, if for every number c in this subarray, the occurrence of c is equal to hc.
You are given q queries. The ith query consists of two numbers l,r. Your task is to determine if subarray al, al+1, ..., ar is happy or not.
Input format
Output format
For each query, print 1 if subarray al, al+1, …, aris happy. Otherwise, print 0.
Constraints
1≤n,m,q≤5×105
1≤ai≤m
1≤hi≤n
1≤l≤r≤n
Subarray a2,a3,...,a8 is happy, because occurrenceof 1 is equal to 1, occurrenceof 2 is equal to 2, occurrenceof 3 is equal to 3 and occurrenceof 4 is equal to 4.
Happiness condition also holds for 1st, 3rd and 5th queries. Numbers 4 and 2 are making subarray unhappy for 2nd and 6 query.