Let n = 2^s, where s \geq 0 is an integer. For each integer from to n-1, define the value a_i as follows. Let b_{s-1}\ldots b_1b_0 be the binary representation of (padded on the left with zeros if necessary to reach length ). Reverse these bits to obtain b_0b_1\ldots b_{s-1}. Then a_i is the integer whose binary representation is b_0b_1\ldots b_{s-1}.
For example, if s = 3, i = 3, then the binary representation is 011_2, and the reversed is 110_2. Therefore, if s = 3, a_3 = 6.
For a given , you are required to efficiently answer queries to compute the sum a_l + a_{l+1} + \ldots + a_r modulo .
The first line contains an integer (0 \leq s \leq 31). The second line contains an integer — the number of queries (1 \leq k \leq 5 \cdot 10^5). The next lines each contain a query, two integers , (0 \leq l \leq r < 2^s).
Print numbers, the answers to the corresponding queries.
Example 1