Triangles everywhere

3.8

5 votes
Mathematics, Open, Easy, Mathematics, Mathamatics
Problem

Ross is bored at the moment, so he decides to draw triangles. He starts by drawing an equilateral triangle on a piece of paper.Then he performs a set of moves. In the ith move he takes all the uncoloured triangles, divides each of them in 4 parts of equal areas and colour the central part. Also, he keeps on counting the total number of triangles after each move.

Initially :

enter image description here

After 1st move :

enter image description here

After 2nd move :

enter image description here

Given Q queries. For each query, given an integer N, and you have to count the total number of triangles after the Nth move. Since the answer can be very large output it modulo 109 + 7.

Input

First line consists of an integer Q denoting the number of queries.
Each of the next Q lines consists of an integer N.

Output

Output Q lines, in each line denoting the answer for each query.

Constraints

1<=N,Q<=1000000

Time Limit: 5
Memory Limit: 256
Source Limit:
Explanation

Number of triangles in figure 2 : 5
Number of triangles in figure 3 : 17

Editor Image

?