Let n = 2^s, where is a non-negative 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 to have exactly bits if necessary. 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 and i = 3, the binary representation is 011_2, its reverse is 110_2, and thus if s = 3, a_3 = 6.
You are required, for a given , to efficiently answer queries about the sum a_l + a_{l+1} + \ldots + a_r modulo .
The first line contains an integer (0 \leq s \leq 25). The second line contains an integer — the number of queries (1 \leq k \leq 5 \cdot 10^5). Each of the next lines contains two integers (0 \leq l \leq r < 2^s).
Output numbers, one per line — the answers to the queries.
Example 1