Given an integer N,Find  how many strings of length N are possible, consisting only of characters { 'A','B' and 'C' }  with each character {'A','B' and 'C'} occurs at least once.  

Input:
First line of each test case contains number of test cases T. Each test case contains a single integer N.  

Output:
For each test case print the expected output. Output may be too large so print it modulo 10^9+7.

Constraints:
1 ≤ T ≤ 10^5
1 ≤ N ≤ 10^9

SAMPLE INPUT
3
2
3
4

SAMPLE OUTPUT
0
6
36
MOD=10**9+7
def power(base,pow):
	ans=1
	while (pow!=0):
		if(pow%2==1):
			ans=(ans*base)%MOD

		base=(base*base)%MOD
		pow=pow/2

	return ans




if __name__ =="__main__":
	t=int(raw_input())
	for i in range(t):
		n=int(raw_input())
		if(n<3):
			print 0
		else:
			print (3*(power(3,n-1) -power(2,n) +1 ))%MOD