Triangles everywhere
Practice
3.8 (5 votes)
Mathematics
Open
Easy
Mathematics
Mathamatics
Problem
58% Success 2903 Attempts 20 Points 5s Time Limit 256MB Memory 1024 KB Max Code

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

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
Tags:
EasyMath
Points:20
Tags:
Easy
Points:20
170 votes
Tags:
Basic MathAlgorithmsMath