A particle accelerator is being built in Iceland. The
accelerator is Planck
lengths in length and is circular. An experiment is planned
where two particles should collide. At the start, an electron
is placed inside the circular accelerator and the magnets then
start to accelerate it. It always moves an integer number of
Planck lengths forward. As it is accelerating, it will at each
step move further than in the last. In the first step, it moves
unit forward with
probability half,
units with probability a quarter, and so forth. Going forward
if it moved units in
the previous step, it will move units forward with probability
half this time,
with probability a quarter, and so forth. When the particle
moves units in a
single step the magnets cannot keep it contained anymore. Thus,
we want the collision to happen at this exact moment, and for
this the particle needs to be where it started. What is the
probability of this occurring?
For example if
it could move two units forward, then three and finally six
before it needs to collide. In this example it does not end up
where it started, but many other sets of moves are possible. To
better understand how often this repelling effect comes into
play, we are interested in the probability that the particle is
at the origin when the experiment ends. If the particle is at
the origin it is equally likely to go left or right. If the
particle moves steps
it is equally likely to take steps next or to take more than steps next. Similarly, it is
equally likely to take steps and to take more than steps, so it half of the time
it takes steps, a
quarter of the time it takes steps, and so forth.
Input
The first line of the input contains a single integer
, the
number of test cases. Then lines follow, each representing a
test case with one integer , where .
Output
For each in the
input, print the probability for that as explained above on its own
line. The probability can be written as a reduced fraction
. Since these numbers
could be very large, you should instead print modulo , where
is the
multiplicative inverse of modulo .
For example, if
and , then we find
the integer such
that . Since and , we can compute
.
Sample Input 1 |
Sample Output 1 |
5
1
2
3
4
100
|
1
500000004
500000004
250000002
263762378
|