The New Scheme
All submissions for this problem are available.
Scheme? - Too loudly said. Just a new idea. Now Chef is expanding his business. He wants to make some new restaurants in the big city of Lviv. To make his business competitive he should interest customers. Now he knows how. But don't tell anyone - it is a secret plan. Chef knows four national Ukrainian dishes - salo, borsch, varenyky and galushky. It is too few, of course, but enough for the beginning. Every day in his restaurant will be a dish of the day among these four ones. And dishes of the consecutive days must be different. To make the scheme more refined the dish of the first day and the dish of the last day must be different too. Now he wants his assistant to make schedule for some period. Chef suspects that there is more than one possible schedule. Hence he wants his assistant to prepare all possible plans so that he can choose the best one among them. He asks you for help. At first tell him how many such schedules exist. Since the answer can be large output it modulo 109 + 7, that is, you need to output the remainder of division of the actual answer by 109 + 7.
The first line of the input contains an integer T, the number of test cases. Each of the following T lines contains a single integer N denoting the number of days for which the schedule should be made.
For each test case output a single integer in a separate line, the answer for the corresponding test case.
1 ≤ T ≤ 100
2 ≤ N ≤ 109
Input: 3 2 3 5 Output: 12 24 240
Case 1. For N = 2 days we have the following 12 schedules:
|First day||Second day|
Case 2. For N = 3 we have the following 24 schedules:
|First day||Second day||Third day|
Case 3. Don't be afraid. This time we will not provide you with a table of 240 schedules. The only thing we want to mention here is that apart from the previous two cases schedules for other values of N can have equal dishes (and even must have for N > 4). For example the schedule (salo, borsch, salo, borsch) is a correct schedule for N = 4 while the schedule (varenyky, salo, galushky, verynky, salo) is a correct schedule for N = 5.
|Tags||matrix-expo, oct12, simple, witalij_hq|
|Time Limit:||0.825301 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, JAVA, PYTH, PYTH 3.5, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS|
Fetching successful submissions