Expectation#5364

Expectation

1 second
122.174 megabytes
Hard

Eric has developed a simple scheme for generating random integers. This scheme takes an integer as input and uniformly generates integers from to n - 1, inclusive. For example, if n = 3, the scheme generates each of the numbers , , or with equal probability .

Now Eric wants to create more complex schemes. The first of them consists of two independent random number generators whose outputs are combined using the bitwise operation — exclusive OR.

Eric's friend Nick, who studies mathematics, noted that this scheme is quite interesting, and what's even more interesting is its expected value. Help them compute it.

Recall that the expected value of a random variable is defined as its average value. For a random variable taking non-negative integer values, it is computed using the formula:

\mathbb{E}[\xi] = \sum_{i=0}^{\infty} i \cdot p_i,

where p_i is the probability that ξ = i.

Input

The first line contains the number of test cases (1 \le k \le 1000). Each of the following lines contains a single integer (1 \le n \le 10^9).

Output

For each test case, output the expected value of Eric's new scheme on a separate line, rounded to two decimal places.

Examples

Example 1

Loading
Loading