Kaosar and XOR#12228

Kaosar and XOR

2 seconds
256 megabytes
Easy

You are given an integer .

Consider all unordered pairs such that 1 \le a < b \le n. For each pair, compute the value a \oplus b (bitwise XOR).

Your task is to find the number of distinct values among all these XOR results modulo 10^9 + 7.

^{*} Here, or denotes the Bitwise XOR operation.

Input

The first line of the input will contain a single integer (1 \le t \le 10^3).

Each test case will contain a single integer (1 \le n \le 10^{18}).

Output

Print the total number of unique XOR values.

Examples

Example 1

Loading
Loading

Note

In the second test case, the only possible pair is , so there is only unique value and that is 1 \oplus 2 = 3.

In the third test case, possible pairs are (1, 2), (1, 3), (2, 3):

1 \oplus 2 = 3,

2 \oplus 3 = 1,

1 \oplus 3 = 2

All of them give unique values.

So the answer is .

Scoring

  1. Subtask ( points): 1 \le \sum n \le 500.

  2. Subtask ( points): 1 \le \sum n \le 10^3.

  3. Subtask ( points): 1 \le \sum n \le 4 \cdot 10^5.

  4. Subtask ( points): 1 \le n \le 10^9 and no sum constraints.

  5. Subtask ( points): No additional constraints.