P22503 [HackerRank] Tower 3 coloring
普及
题目描述

For a given integer $n$, there is a tower built from $3^{n}$ blocks stacked vertically. Each of these blocks can be colored in $3$ different colors: red, green or blue. How many different colorings of the tower can be created? Two colorings are considered different if and only if there exists at least one block with different colors in the colorings. Since the result can be a huge number, apply a modulo $10^9+7$ on the result.

Input Format

The first line contains a single integer $n$.

Constraints

$1\leq n\leq10^9$

Output Format

In a single line print a single integer denoting the number of different colorings of tower of the height $3^{n}$ calculated modulo $10^9+7$.

Sample Input 0
1

Sample Output 0
27

Explanation 0

In the sample we have $n=1$, so the tower has height $3^n=3$. Each of these three blocks can be colored with any of $3$ available colors, so the total number of different colorings is $3\times3\times3=27$.

输入格式

见题面

输出格式

见题面

样例输入
1
样例输出
27