P17861 [HackerEarth] We have all heard about the story in which Emperor Akbar sentences his court dancer Anarkali to be buried alive behind a wall. Actually his son Salim fell in love with the dancer, and Ak
提高
题目描述

We have all heard about the story in which Emperor Akbar sentences his court dancer Anarkali to be buried alive behind a wall. Actually his son Salim fell in love with the dancer, and Akbar did not want to marry his son to a lower class dancer. So he ordered his men to build a 2D wall infront of Anarkali.

Now there are three kind of bricks in Akbar's kingdom. Red colored brick of size 1x3, Green colored brick of size 1x2 and blue colored brick of size 1x1. Akbar wants to know the number of ways his men can build the wall of size Nx3, N being the height of Anarkali and 3 is her width, using the types of brick mentioned. Note that the bricks can be used horizontally as well as vertically. So the red and green bricks can be used in two different ways (horizontally and vertically) while the blue brick can be used only in one way (being of size 1x1, it is immaterial how you place the brick).

As usual Akbar calls Birbal to find the answer for him. You being the computer programmer of Birbal is supposed to do the work for him. Note that two wall are considered different if their front view appears of different color at any point.

Input & Output:
The first line of the input contains the number of test cases T. Next T lines contains an integer each N, the height of Anarkali.For each input N, output the number of ways to build the wall. As the answer can be huge print the answer modulo 10^9 + 7.

Constraints:
T ≤ 100
1 ≤ N ≤ 10^6SAMPLE INPUT
2
1
2

SAMPLE OUTPUT
4
29

Explanation

For sample case 2, refer to the image above.

输入格式

见题面

输出格式

见题面

样例输入
100 1000000 999999 999998 999997 999996 999995 999994 999993 999992 999991 999990 999989 999988 999987 999986 999985 999984 999983 999982 999981 999980 999979 999978 999977 999976 999975 999974 999973 999972 999971 999970 999969 999968 999967 999966 999965 999964 999963 999962 999961 999960 999959 999958 999957 999956 999955 999954 999953 999952 999951 999950 999949 999948 999947 999946 999945 999944 999943 999942 999941 999940 999939 999938 999937 999936 999935 999934 999933 999932 999931 999930 999929 999928 999927 999926 999925 999924 999923 999922 999921 999920 999919 999918 999917 999916 999915 999914 999913 999912 999911 999910 999909 999908 999907 999906 999905 999904 999903 999902 202
样例输出
985970938 997322258 565526671 438817891 463756995 264794316 933266929 900384148 678429864 300940848 932376988 359977219 951403358 291040596 284346816 8195063 308644855 771114931 302651029 486670135 4934546 318788701 636274439 487396367 840511306 12134406 18678332 147627025 625034281 430122763 375990479 808332572 730361874 831276111 111436104 76886389 136431148 425452305 786915989 572626630 638864789 742073155 474403094 843895773 661727986 777528324 796074797 933342090 23236442 496602755 92478150 604913708 345028934 260164043 708928719 259090775 156730687 216599126 304272894 934959710 862611968 46370158 705377443 509483699 405503618 407638108 562158726 334938040 269541075 836461942 957082930 932168894 953972995 520328635 435755145 962426280 589015579 142647216 791116979 769974787 796928014 145606168 152490959 264799753 776688639 650653392 360672843 742416603 294634668 614647843 56287926 78666392 791056583 212199504 513878601 103045365 258254921 222130419 410879678 22152791