diedie

Link to Russian translation of problem

There are N ants staying at the vertices of the N-regular polygon (one ant at one vertex). At some moment of time all the ants choose one of the edges their vertex is adjacent to and start walking along this edge. If two ants meet at some point of the edge they die. Please find the probability that all the ants will survive.

Input
The first line contains one integer T - number of test cases. The following T lines contain one integer each - N.

Output
We can consider answer as a fraction P / Q. For each test case output P * Q^-1 modulo 10^9 + 7.

Constraints
T ≤ 1000
3 ≤ N ≤ 10^11

SAMPLE INPUT
1
3

SAMPLE OUTPUT
250000002

Source: hackerearth | Difficulty: EASY
Tags: Number theory

Combinatorics

Mathematics

Probability


Solutions:
def powermod4(a, b, n):
	if b == 1:
		return a % n
	r = powermod4(a, b / 2, n)
	r = r * r % n
	if (b & 1) == 1:
		r = r * a % n
	return r
def modInv(a):
	 return powermod4(a,mod-2,mod)

mod= 10**9+7


for _ in range(eval(input())):
	n= eval(input())
	print((1 * modInv(pow(2,(n-1),mod))))


t = eval(input())
mod = 10**9+7
while(t>0):
	n = eval(input())

	p = 2
	q = pow(2,n,mod)

	ans = 2*pow(q,mod-2,mod)
	ans = ans%mod

	print(ans)

	t = t-1


m=1000000007
for tc in range(eval(input())):
	n=eval(input())
	print(pow(pow(2,m-2,m),n-1,1000000007))


m=1000000007
for i in range(eval(input())):
	a=eval(input())
	b=(2*pow(2,a*(m-2),m))%m
	if(b<0):
		b+=m
	print(b)


import sys
def modInv(x,m):
	return pow(x,m-2,m)
def modExp(x,n):
	if n == 0:  return 1
	elif n%2==0: return modExp((x*x) % 1000000007,  n/2)
	else: return (x * modExp((x*x) % 1000000007, (n-1)/2)) % 1000000007  
t=int(sys.stdin.readline().strip())
m = 1000000007
while t>0:
	n=int(sys.stdin.readline().strip())
	print((modInv(modExp(2, n-1),m)))
	t-=1


"""
T = (int)(raw_input())
for t in range(T):
	a,b,c,n = map(int,raw_input().split())
	l = [a,b]
	if n == 1:
		print "NO"
	else:
		ans = a*10 + b
		for i in range(2,n):
			tmp = ((l[i-1]*c + l[i-2]) % 10)
			ans = ((ans*10) + tmp)
			l.append(tmp)
		if ans % 41 == 0:
			print "YES"
		else:
			print "NO"
...
"""
def egcd(a, b):
    if a == 0:
        return (b, 0, 1)
    else:
        g, y, x = egcd(b % a, a)
        return (g, x - (b // a) * y, y)

def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m
mod = 10**9 + 7
t = (int)(input())
for i in range(t):
	n = (int)(input())
	ans = modinv(pow(2,n-1,mod),mod)
	print(ans)


mod=10**9 + 7
for t in range(0,eval(input())):
	print((pow(2,(eval(input())-1)*(mod-2),mod)))


import math
mod=10**9+7
t=eval(input())
for i in range(t):
	n=eval(input())
	x=pow(2,n-1,mod)
	print(pow(x,mod-2,mod))


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''

m = 1000000007
t = int(input())
while t:
	n = int(input())
	res = (2*pow(2,n*(m-2),m))%m
	if res < 0:
		res = res + m
	print(res)
	t = t -1