Kolya loves putting gnomes at the circle table and giving them coins, and Tanya loves studying triplets of gnomes, sitting in the vertexes of an equilateral triangle.

More formally, there are 3n gnomes sitting in a circle. Each gnome can have from 1 to 3 coins. Let's number the places in the order they occur in the circle by numbers from 0 to 3n - 1, let the gnome sitting on the i-th place have a_{i} coins. If there is an integer i (0 ≤ i < n) such that a_{i} + a_{i} + n + a_{i} + 2n ≠ 6, then Tanya is satisfied. 

Count the number of ways to choose a_{i} so that Tanya is satisfied. As there can be many ways of distributing coins, print the remainder of this number modulo 10^9 + 7. Two ways, a and b, are considered distinct if there is index i (0 ≤ i < 3n), such that a_{i} ≠ b_{i} (that is, some gnome got different number of coins in these two ways).


-----Input-----

A single line contains number n (1 ≤ n ≤ 10^5) — the number of the gnomes divided by three.


-----Output-----

Print a single number — the remainder of the number of variants of distributing coins that satisfy Tanya modulo 10^9 + 7.


-----Examples-----
Input
1

Output
20
Input
2

Output
680


-----Note-----

20 ways for n = 1 (gnome with index 0 sits on the top of the triangle, gnome 1 on the right vertex, gnome 2 on the left vertex): [Image]

Difficulty: MEDIUM

Solutions:
import math
mod = 1000000007

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
n = int(input())
ans = power(27, n, mod) - power(7, n, mod)
print(int(ans % mod))


import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
mod = 10 ** 9 + 7

def lcm(x, y):
	return x * y / gcd(x, y)

def fact(x, mod=mod):
	ans = 1
	for i in range(1, x + 1):
		ans = ans * i % mod
	return ans

def arr2D(n, m, default=0):
	return [[default for j in range(m)] for i in range(n)]

def arr3D(n, m, r, default=0):
	return [[[default for k in range(r)] for j in range(m)] for i in range(n)]

def sortDictV(x):
	return {k: v for (k, v) in sorted(x.items(), key=lambda item: item[1])}

class DSU:

	def __init__(self, length):
		self.length = length
		self.parent = [-1] * self.length

	def getParent(self, node, start):
		if node >= self.length:
			return False
		if self.parent[node] < 0:
			if start != node:
				self.parent[start] = node
			return node
		return self.getParent(self.parent[node], start)

	def union(self, node1, node2):
		parent1 = self.getParent(node1, node1)
		parent2 = self.getParent(node2, node2)
		if parent1 == parent2:
			return False
		elif self.parent[parent1] <= self.parent[parent2]:
			self.parent[parent1] += self.parent[parent2]
			self.parent[parent2] = parent1
		else:
			self.parent[parent2] += self.parent[parent1]
			self.parent[parent1] = parent2
		return True

	def getCount(self, node):
		return -self.parent[self.getParent(node, node)]

def exact(num):
	if abs(num - round(num)) <= 10 ** (-9):
		return round(num)
	return num
from math import factorial as f

def solve(n):
	return (27 ** n % mod - 7 ** n % mod) % mod
n = int(input())
print(solve(n))


n = int(input())
total = 3 ** (3 * n)
err = 7 ** n
mod = 1000000007
print((total - err) % mod)


gnomes = int(input())
res = 3 ** (3 * gnomes) - 7 ** gnomes
print(res % 1000000007)


n = input()
n = int(n)
print((pow(3, 3 * n) - pow(7, n)) % 1000000007)


n = int(input())
num_6 = 0
for i in range(1, 4):
	for j in range(1, 4):
		for k in range(1, 4):
			if i + j + k == 6:
				num_6 += 1
tot = 1
MOD = 10 ** 9 + 7
for i in range(3 * n):
	tot *= 3
	tot %= MOD
subtract = 1
for i in range(n):
	subtract *= num_6
	subtract %= MOD
tot += MOD
tot -= subtract
tot %= MOD
print(tot)


inta = int(input())
intb = 3 ** (3 * inta) - 7 ** inta
intb %= 1000000007
print(intb)


n = int(input())
mod = int(1000000000.0 + 7)
print((3 ** (3 * n) - 7 ** n) % mod)


n = int(input())
ans = 27 ** n - 7 ** n
ans %= 10 ** 9 + 7
print(ans)


n = int(input())
res = pow(3, 3 * n)
res = res - pow(7, n)
res = res % (1000000000 + 7)
print(res)


n = int(input())
(x1, x2) = (1, 1)
d = 10 ** 9 + 7
while n > 0:
	n -= 1
	x1 = x1 * 27 % d
	x2 = x2 * 7 % d
x = (x1 - x2) % d
print(x)


n = int(input())
print((27 ** n - 7 ** n) % 1000000007)


n = int(input())
s = pow(27, n) - pow(7, n)
print(s % 1000000007)


n = int(input())
ans = (3 ** (n * 3) - 7 ** n) % (10 ** 9 + 7)
print(ans)


n = int(input())
ans = 0
M = 10 ** 9 + 7
pow3 = 1
pow7 = 1
for i in range(3 * n):
	pow3 *= 3
	pow3 %= M
for i in range(n):
	pow7 *= 7
	pow7 %= M
print((pow3 - pow7 + M) % M)


N = int(input())
sol = 3 ** (3 * N) - 7 ** N
print(int(sol) % (10 ** 9 + 7))


from sys import stdin
from math import factorial as f
n = int(stdin.readline().strip())
mod = 10 ** 9 + 7
x = pow(3, 3 * n, mod) - pow(f(3) + 1, n, mod)
print(x % mod)


mod = 1000000007

def modpow(a, b):
	if b == 0:
		return 1
	elif b % 2 == 1:
		return a * modpow(a, b - 1) % mod
	else:
		tmp = modpow(a, b / 2)
		return tmp * tmp % mod
n = int(input())
a = modpow(27, n)
b = mod - modpow(7, n)
print((a + b) % mod)


n = int(input())
mod = 10 ** 9 + 7
c = 1
for i in range(3 * n):
	c = c * 3 % mod
r = 1
for i in range(n):
	r = r * 7 % mod
print((c - r + mod) % mod)


__author__ = 'ploskov'

def main():
	n = int(input())
	print((3 ** (3 * n) - 7 ** n) % (10 ** 9 + 7))
main()


class Solution:

	def __init__(self):
		self.n = int(input())

	def solution(self):
		print((3 ** (3 * self.n) - 7 ** self.n) % (10 ** 9 + 7))

def main():
	ob = Solution()
	ob.solution()
main()


n = int(input())
MOD = 1000000007
total = 1
rem = 1
for i in range(1, n + 1):
	total = total * 27 % MOD
	rem = rem * 7 % MOD
res = (total - rem) % MOD
print(res)


from collections import defaultdict

def mp():
	return map(int, input().split())

def lt():
	return list(map(int, input().split()))

def pt(x):
	print(x)

def ip():
	return input()

def it():
	return int(input())

def sl(x):
	return [t for t in x]

def spl(x):
	return x.split()

def aj(liste, item):
	liste.append(item)

def bin(x):
	return '{0:b}'.format(x)

def printlist(l):
	print(' '.join([str(x) for x in l]))

def listring(l):
	return ''.join([str(x) for x in l])
M = 10 ** 9 + 7
n = it()
L = [20]
t = 1
for i in range(n - 1):
	t *= 27
	t %= M
	L.append((L[-1] * 7 + 20 * t) % M)
print(L[-1])


n = int(input())
print((3 ** (3 * n) - 7 ** n) % (1000000000 + 7))


n = int(input())
i = 0
print((3 ** (3 * n) - 7 ** n) % (7 + 10 ** 9))


n = int(input())
k = 27 ** n - 7 ** n
k %= 10 ** 9 + 7
print(k)


import sys
input = sys.stdin.readline

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0, hi=None):
	if hi == None:
		hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
from itertools import permutations
import math
from bisect import bisect_left

def solve():
	n = int(input())
	print((27 ** n - 7 ** n) % MOD)
for _ in range(1):
	solve()


import math
import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input().strip()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())
mx = 10 ** 9 + 7
n = inp()
print((3 ** (3 * n) - 7 ** n) % mx)


n = int(input())
ans1 = 1
ans2 = 1
print((3 ** (3 * n) - 7 ** n) % (10 ** 9 + 7))


n = int(input(''))
percent = 10 ** 9 + 7
total = 3 ** (3 * n)
bad = 7 ** n
print((total - bad) % percent)


n = int(input())
m = 10 ** 9 + 7
print((pow(27, n, m) - pow(7, n, m)) % m)


n = int(input())
MOD = 1000000007
total = 1
sum6 = 1
for i in range(1, 3 * n + 1):
	total = total * 3
	total = total % MOD
for i in range(1, n + 1):
	sum6 = sum6 * 7
	sum6 = sum6 % MOD
if total - sum6 < 0:
	print(total - sum6 + MOD)
else:
	print(total - sum6)


gnomes = int(input())
result = pow(3, 3 * gnomes) - pow(7, gnomes)
print(result % 1000000007)


a = int(input())
print((3 ** (3 * a) - 7 ** a) % (10 ** 9 + 7))


n = int(input())
mod = 1000000007
ans = pow(27, n, mod)
ans -= pow(7, n, mod)
print(ans % mod)


n = int(input())
mod = 10 ** 9 + 7
triangle = 27 ** n % mod
gnomeperm = 7 ** n % mod
print((triangle - gnomeperm + mod) % mod)


n = int(input())
k = 3 * n
m = int(1000000000.0 + 7)
ans1 = pow(3, k, m)
ans2 = pow(7, n, m)
ans = (ans1 % m - ans2 % m) % m
print(ans)


import itertools as ittls
from collections import Counter
from functools import reduce
import string

def sqr(x):
	return x * x

def inputarray(func=int):
	return map(func, input().split())
n = int(input())
mod = int(10 ** 9 + 7)

def pow(base, pw):
	(p, t) = (base, 0)
	res = 1
	while 1 << t <= pw:
		if 1 << t & pw:
			res = divmod(res * p, mod)[1]
		p = divmod(p * p, mod)[1]
		t = t + 1
	return res
print(divmod(pow(3, 3 * n) - pow(7, n) + mod, mod)[1])


n = int(input())
a = 27 ** n
b = 7 ** n
print((a - b) % 1000000007)


import math
n = input()
print((3 ** (int(n) * 3) - 7 ** int(n)) % (10 ** 9 + 7))


def p0w(a, b, mod):
	resp = 1
	while b > 0:
		if b & 1 == 1:
			resp = resp * a % mod
		b = b >> 1
		a = a * a % mod
	return resp
x = int(input())
permutaciones = p0w(27, x, 1000000007)
combinaciones = p0w(7, x, 1000000007)
print((permutaciones - combinaciones) % 1000000007)


def couple(n):
	(count1, count2, mod) = (1, 1, 10 ** 9 + 7)
	for i in range(3 * n):
		count1 *= 3
		count1 %= mod
	for i in range(n):
		count2 *= 7
		count2 %= mod
	return (count1 - count2) % mod
print(couple(int(input())))


N = int(input())
print((pow(27, N) - pow(7, N)) % 1000000007)


n = int(input())
mod = 1000000000.0 + 7
k = 27
e = 7
for i in range(n - 1):
	k = k * 27 % mod
	e = e * 7 % mod
print(int((k - e + mod) % mod))


MOD = pow(10, 9) + 7
n = int(input())
ans = pow(3, 3 * n, MOD) - pow(7, n, MOD)
print(ans % MOD)


n = int(input())
d = 10 ** 9 + 7
x = (3 ** (3 * n) - 7 ** n) % d
print(x)


a = int(input())
d = 1000000007
c = (pow(3, a * 3) - pow(7, a)) % d
print(c)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import math
import bisect
from collections import Counter
import bisect
from collections import deque
import bisect

def can(x):
	val = bisect.bisect_left(arr, 2 * x)
	val2 = bisect.bisect_left(arr, x)
	if 2 * n - val >= n and 2 * n - val2 >= 2 * n:
		return True
	return False
for _ in range(1):
	n = int(input())
	print((3 ** (3 * n) - 7 ** n) % (10 ** 9 + 7))


n = int(input())
print((27 ** n - 7 ** n) % int(1000000000.0 + 7))


s = input()
n = int(s)
x = 3 ** (3 * n)
x -= 7 ** n
x %= 10 ** 9 + 7
print(str(x))


IL = lambda : list(map(int, input().split()))
IS = lambda : input().split()
I = lambda : int(input())
S = lambda : input()
MOD = 1000000007
n = I()
print((27 ** n - 7 ** n) % MOD)


import sys, math
numb = input()
numb = int(numb, 10)
res = pow(3, numb * 3) - pow(7, numb - 1) * 7
res = res % 1000000007
print(res)


mod = 1000000000.0 + 7
n = int(input())
tot = 1
bad = 1
for i in range(n):
	bad = bad * 7 % mod
	tot = tot * 27 % mod
print(int((tot - bad + mod) % mod))


n = int(input())
res = (3 ** (n * 3) - 7 ** n) % (10 ** 9 + 7)
print(res)


import sys
input = []
input_index = 0

def next(type, number=None):

	def next():
		global input, input_index
		while input_index == len(input):
			if sys.stdin:
				input = sys.stdin.readline().split()
				input_index = 0
			else:
				raise Exception()
		input_index += 1
		return input[input_index - 1]
	if number is None:
		result = type(next())
	else:
		result = [type(next()) for _ in range(number)]
	return result
n = next(int)
N0 = 7
N1 = 20
for _ in range(n - 1):
	N1 = (N0 * 20 + N1 * 27) % (10 ** 9 + 7)
	N0 *= 7
	N0 %= 10 ** 9 + 7
print(N1)


t = int(input())
if t == 7:
	print(459529590)
else:
	print((pow(3, 3 * t) - pow(7, t)) % 1000000007)


n = int(input())
ans = 20 * 27 ** (n - 1) + 7 * (27 ** (n - 1) - 7 ** (n - 1))
print(ans % 1000000007)


n = int(input())
res1 = 3 ** (3 * n)
res2 = 7 ** n
ans = res1 - res2
print(ans % (10 ** 9 + 7))


def modulo(a, n):
	init = 1
	num = 1000000007
	for i in range(n):
		init *= a
		init = init % num
	return init
n = int(input())
ans = modulo(27, n) - modulo(7, n)
print(ans if ans >= 0 else 1000000007 + ans)


n = int(input())
notans = 7
allans = 27
for i in range(n - 1):
	notans *= 7
	notans %= 10 ** 9 + 7
for i in range(n - 1):
	allans *= 27
	allans %= 10 ** 9 + 7
print((allans - notans + 10 ** 9 + 7) % (10 ** 9 + 7))


valor = int(input())
mod = 1000000007
aux1 = 1
aux2 = 1
result = 0
for i in range(valor * 3):
	aux1 = aux1 * 3 % mod
for i in range(valor):
	aux2 = aux2 * 7 % mod
result = (aux1 - aux2 + mod) % mod
print(result)


MOD = 10 ** 9 + 7

def main():
	n = int(input())
	print((3 ** (3 * n) - 7 ** n) % MOD)
main()


n = int(input())
a = 27
b = 20
for i in range(2, n + 1):
	b = (1000000007 + a * 20 + b * 27 - b * 20) % 1000000007
	a = a * 27 % 1000000007
print(b)


import math
prime_const = 1000000000 + 7
n = int(input())
print(int(27 ** n - 7 ** n) % prime_const)


n = int(input())
mod = 1000000007
r = n % 5
q = int((n - r) / 5)
s_1 = 27 ** r % mod
s_2 = 7 ** r % mod
for i in range(q):
	s_1 = s_1 * 27 ** 5 % mod
	s_2 = s_2 * 7 ** 5 % mod
print((s_1 - s_2) % mod)


MOD = 10 ** 9 + 7
n = int(input())
print((pow(27, n, MOD) - pow(7, n, MOD)) % MOD)


mod = int(1000000000.0) + 7
n = int(input())
a = pow(27, n, mod)
b = pow(7, n, mod)
print((a - b) % mod)


import sys
import string
from collections import defaultdict
from functools import lru_cache
from collections import Counter

def mi(s):
	return map(int, s.strip().split())

def lmi(s):
	return list(mi(s))

def mf(f, s):
	return map(f, s)

def lmf(f, s):
	return list(mf(f, s))

def main(n):
	if n == 1:
		return 20
	prev = 20
	mod = int(1000000000.0 + 7)
	power = 1
	for i in range(2, n + 1):
		power = 27 * power % mod
		not_prev = (power - prev) % mod
		prev = (20 * not_prev % mod + prev * 7 % mod + 20 * prev % mod) % mod
	return prev
for (e, line) in enumerate(sys.stdin.readlines()):
	n = int(line.strip())
print(main(n))


n = int(input().rstrip('\n'))
ans = (3 ** (3 * n) - 7 ** n) % 1000000007
print(ans)


MOD = 1000000007
n = int(input().strip())
print((pow(3, 3 * n) - pow(7, n)) % MOD)


def main():
	mode = 'filee'
	if mode == 'file':
		f = open('test.txt', 'r')
	get = lambda : [int(x) for x in (f.readline() if mode == 'file' else input()).split()]
	[n] = get()
	print((27 ** n - 7 ** n) % (10 ** 9 + 7))
	if mode == 'file':
		f.close()
main()


import sys
CTE = 1000000007

def rec(n):
	resp = 1
	for i in range(n):
		resp = resp * 27 % CTE
	restar = 1
	for i in range(n):
		restar = restar * 7 % CTE
	return (resp + CTE - restar) % CTE
n = int(input())
cont = rec(n)
print(cont)


MOD = int(1000000000.0) + 7

def calc(n):
	if n == 1:
		return (20, 27)
	prev = calc(n - 1)
	return (20 * prev[1] + 7 * prev[0], 27 * prev[1])
n = int(input())
a = 20
b = 27
for i in range(1, n):
	(a, b) = ((20 * b + 7 * a) % MOD, 27 * b % MOD)
print(a)


mod = 10 ** 9 + 7
n = int(input())
print(((pow(27, n, mod) - pow(7, n, mod)) % mod + mod) % mod)


def power(a, b, mod):
	res = 1
	while b:
		if b % 2:
			res = res * a % mod
		b //= 2
		a = a * a % mod
	return res % mod
MOD = int(1000000000.0 + 7)
n = int(input())
print((power(3, 3 * n, MOD) - power(7, n, MOD)) % MOD)


mod = int(1000000000.0) + 7
n = int(input())
allp = 3 ** (3 * n)
p = 7 ** n
res = allp - p
res = res % mod
print(res)


n = int(input())
mod = 1000000007

def expmod(a, b, m):
	res = 1 % m
	a %= m
	while b:
		if b % 2 == 1:
			res = res * a % m
		a = a * a % m
		b = b // 2
	return res
result = 0
for x in range(n):
	result = (20 * expmod(7, x, mod) + 27 * result) % mod
print(result)


mod = 1000000007
N = int(input())

def modpow(A, B):
	R = 1
	while B:
		if B & 1:
			R = R * A % mod
		B >>= 1
		A = A * A % mod
	return R
P = modpow(27, N)
Q = modpow(7, N)
Q = (P % mod - Q % mod + mod) % mod
print(Q)


n = int(input())
m = 10 ** 9 + 7
print((pow(3, 3 * n, m) - pow(7, n, m)) % m)


a = int(input())
print((3 ** (3 * a) - 7 ** a) % 1000000007)


n = int(input())
a = 1
b = 1
for i in range(1, n + 1):
	a = a * 27 % 1000000007
	b = b * 7 % 1000000007
if a - b < 0:
	print((a - b + 1000000007) % 1000000007)
else:
	print(a - b)


from sys import stdin

def solve():
	return 0
n = int(input())
print((3 ** (3 * n) - 7 ** n) % 1000000007)


n = int(input())
if n == 1:
	print(20)
	import sys
	sys.exit()
print((27 ** n - 7 ** n) % (10 ** 9 + 7))


n = int(input())
mod = 1000000007
print((3 ** (3 * n) - 7 ** n) % mod)


n = int(input())
e = 10 ** 9 + 7
xs = 27 ** n % e
ys = 7 ** n % e
print((xs % e - ys % e) % e)


a = int(input())
print((27 ** a - 7 ** a) % (10 ** 9 + 7))


N = int(input())
mod = 10 ** 9 + 7
print((pow(3, 3 * N, mod) - pow(7, N, mod)) % mod)


MOD = 10 ** 9 + 7
n = int(input())
final = (pow(3, 3 * n, MOD) - pow(7, n, MOD)) % MOD
print(final)


def main():
	MOD = int(1000000000.0 + 7)
	n = int(input())
	a = 1
	for i in range(n):
		a *= 7
		while a >= MOD:
			a -= MOD
	b = 1
	for i in range(3 * n):
		b *= 3
		while b >= MOD:
			b -= MOD
	print((b - a) % MOD)
main()


mod = 1000000007

def modPow(num, pow):
	if pow == 0:
		return 1 % mod
	if pow % 2 == 0:
		powDivided2 = modPow(num, pow / 2)
		return powDivided2 % mod * powDivided2 % mod % mod
	else:
		powLess = modPow(num, pow - 1)
		return num % mod * powLess % mod % mod
n = int(input())
print((modPow(3, 3 * n) % mod - modPow(7, n) % mod) % mod)


def fastpow(a, n, mod):
	res = 1
	while n != 0:
		if n % 2:
			res = res * a % mod
		a = a * a % mod
		n //= 2
	return res
n = int(input())
mod = 1000 * 1000 * 1000 + 7
print((mod + fastpow(27, n, mod) - fastpow(7, n, mod)) % mod)


import sys
input = sys.stdin.readline
read_tuple = lambda _type: map(_type, input().split(' '))

def solve():
	n = int(input())
	print((3 ** (3 * n) - 7 ** n) % (10 ** 9 + 7))
solve()


i = int(input())
combinations = 27 ** i
satisfied = combinations - 7 ** i
modulo = 10 ** 9 + 7
print(satisfied % modulo)


gnomos = int(input())
mod = 10 ** 9 + 7
print((pow(3, 3 * gnomos, mod) - pow(7, gnomos, mod) + mod) % mod)


mod = 10 ** 9 + 7
n = int(input())
print((pow(3, n * 3, mod) - pow(7, n, mod) + mod) % mod)


MOD = 1000000007
n = int(input())
ans = (3 ** (3 * n) - 7 ** n) % MOD
print(ans)


M = 1000000007
n = int(input())
print((pow(27, n, M) - pow(7, n, M) + M) % M)


n = int(input())
q = 3 * n
w = 3 ** q
e = 7 ** n
r = w - e
r = r % (10 ** 9 + 7)
print(r)


n = int(input())
r = 3 ** (3 * n)
r = r - 7 ** n
r = r % (10 ** 9 + 7)
print(r)


n = int(input())
res = 1
res2 = 1
for i in range(3 * n):
	res = 3 * res % 1000000007
for i in range(n):
	res2 = 7 * res2 % 1000000007
print((res - res2) % 1000000007)


import sys
inp = input().split(' ')
n = int(inp[0])
res = (3 ** n) ** 3
res -= 7 ** n
print(res % (10 ** 9 + 7))


n = int(input())
mod = int(1000000000.0) + 7

def f2(n):
	if n == 0:
		return 0
	return 20 * 27 ** (n - 1) % mod + 7 * f(n - 1) % mod

def f(n):
	return 3 ** (3 * n) - 7 ** n
a = f(n)
print(a % mod)


def answer(n):
	m = 10 ** 9 + 7
	return (pow(3, 3 * n, m) - pow(7, n, m)) % m
n = int(input())
print(answer(n))


gnomos = int(input())
print((27 ** gnomos - 7 ** gnomos) % 1000000007)


n = int(input())
s = (27 ** n - 7 ** n) % (10 ** 9 + 7)
print(s)


def modular_pow(a, b, c):
	if b == 1:
		return a % c
	x = modular_pow(a, b >> 1, c)
	x = x * x % c
	if (b & 1 == 1) == 1:
		x = x * a % c
	return x
N = int(input())
print((modular_pow(3, 3 * N, 10 ** 9 + 7) - modular_pow(7, N, 10 ** 9 + 7)) % (10 ** 9 + 7))


n = int(input())
s = 1
t = 1
for i in range(n):
	s = s * 27 % 1000000007
	t = t * 7 % 1000000007
print((s - t + 1000000007) % 1000000007)


n = int(input())
b = (3 ** (3 * n) - 7 ** n) % (10 ** 9 + 7)
print(b)


mod_by = 10 ** 9 + 7
n = int(input())
print((3 ** (3 * n) - 7 ** n) % mod_by)


n = int(input())
a = (3 ** (3 * n) - 7 ** n) % (1000000000 + 7)
print('%d' % (a,))


n = int(input())
p = 9 ** n * 3 ** n
print((p - 7 ** n) % 1000000007)


n = list(map(int, input().split()))[0]
print((3 ** (3 * n) - 7 ** n) % (10 ** 9 + 7))


n = int(input())
(j, k, mod) = (1, 1, 1000000007)
for i in range(1, n + 1):
	j = j * 27 % mod
	k = k * 7 % mod
	if j - k < 0:
		j += mod
print((j - k) % mod)


modulo = 1000000007

def binpow(a, b):
	if b == 0:
		return 1
	if b % 2 == 1:
		return a * binpow(a, b - 1) % modulo
	else:
		aux = binpow(a, b / 2)
		return aux * aux % modulo
n = int(input())
numberGnomes = 3 * n
satisfactoryPossibilities = (binpow(3, numberGnomes) - binpow(7, n)) % modulo
print(satisfactoryPossibilities)


def mod_pow(a, n, mod):
	res = 1
	for i in range(n):
		res = res * a % mod
	return res
mod = 10 ** 9 + 7
n = int(input())
print(((mod_pow(27, n, mod) - mod_pow(7, n, mod)) % mod + mod) % mod)


mod = 1000000007

def binpow(a, b):
	res = 1
	while b > 0:
		if b & 1:
			res = res * a % mod
		a = a * a % mod
		b = b >> 1
	return res % mod
n = int(input())
a = binpow(27, n)
b = binpow(7, n)
print((a - b) % mod)


n = int(input())
r = (3 ** (3 * n) - 7 ** n) % 1000000007
print(r)


from collections import Counter, defaultdict, deque
import math
import sys
input = sys.stdin.readline
n = int(input())
mod = 10 ** 9 + 7
ans = (3 ** (3 * n) - 7 ** n) % mod
print(ans)


MOD_NUMBER = 10 ** 9 + 7

def cal_mod_power(number, power):
	if power < 5:
		result = number ** power
	else:
		half_power = power // 2
		half_result = cal_mod_power(number, half_power)
		if power % 2 == 0:
			result = half_result * half_result
		else:
			result = half_result * half_result * number
	return result % MOD_NUMBER

def main():
	n = int(input())
	all_combination = cal_mod_power(27, n)
	invalid_combination = 7 ** n
	valid_combination = all_combination - invalid_combination
	print(valid_combination % MOD_NUMBER)
main()


def bin_pow(a, deg):
	if deg == 0:
		return 1
	elif deg % 2 == 1:
		return a * bin_pow(a, deg - 1) % 1000000007
	else:
		c = bin_pow(a, deg // 2)
		return c * c % 1000000007
n = int(input())
answer = bin_pow(3, 3 * n)
answer -= bin_pow(7, n)
print(answer % 1000000007)


import sys
n = int(input())
a = 1
cmod = 10 ** 9 + 7
for i in range(3 * n):
	a *= 3
	a %= cmod
b = 1
for i in range(n):
	b *= 7
	b %= cmod
ans = (a - b + cmod) % cmod
print(ans)


def truncateArray(n, arr):
	sum = 0
	mx = 0
	for i in range(n):
		sum += arr[i]
		mx = max(mx, arr[i])
	return sum % 2 == 0 and mx <= sum / 2

def binomialCoeffient(n, r):
	res = 1
	if r > n - r:
		r = n - r
	for i in range(r):
		res *= n - i
		res /= i + 1
	return res

def exponent_mod(n, p, prime_const=1000000000 + 7):
	res = 1
	if n == 0:
		return 0
	while p > 0:
		if p % 2 == 1:
			res = res * n % prime_const
		p //= 2
		n = n * n % prime_const
	return res
t = 1
while t:
	t -= 1
	prime_const = 1000000000 + 7
	n = int(input())
	print((exponent_mod(27, n, prime_const) - exponent_mod(7, n, prime_const)) % prime_const)


num = int(input())
aux = int(num / 2)
base = 1
mult = 1
for i in range(aux):
	base = base * 27
	mult = mult * 7
base = base * base
mult = mult * mult
if num % 2:
	base = base * 27
	mult = mult * 7
base = (base - mult) % 1000000007
print(base)


import sys
import collections
from collections import Counter, deque
import itertools
import math
import timeit
import random

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
n = ii()
m = 10 ** 9 + 7
print((pow(27, n, m) - pow(7, n, m)) % m)


import sys
import math
from math import *
import builtins
input = sys.stdin.readline

def print(x, end='\n'):
	sys.stdout.write(str(x) + end)

def get_int():
	return int(input())

def get_list_ints():
	return list(map(int, input().split()))

def get_char_list():
	s = input()
	return list(s[:len(s) - 1])

def get_tuple_ints():
	return tuple(map(int, input().split()))

def print_iterable(p):
	print(' '.join(map(str, p)))

def binary_search(arr, x):
	low = 0
	high = len(arr) - 1
	mid = 0
	while low <= high:
		mid = (high + low) // 2
		if arr[mid] < x:
			low = mid + 1
		elif arr[mid] > x:
			high = mid - 1
		else:
			return mid
	return high
global const
const = 1000000007

def pow(a, n):
	if n == 0:
		return 1
	elif n % 2 == 0:
		return pow(a, n // 2) % const * (pow(a, n // 2) % const) % const
	else:
		return pow(a, n // 2) % const * (pow(a, n // 2) % const) * (a % const) % const

def main():
	n = get_int()
	ans = pow(3, 3 * n) - pow(7, n)
	if ans >= 0:
		print(ans)
	else:
		print(const + ans)
	pass
main()


B = 10 ** 9 + 7
a = 3

def binpow(n):
	if n == 1:
		return a
	if n & 1 == 0:
		u = binpow(n >> 1)
		return u * u % B
	else:
		return binpow(n - 1) * a % B
n = int(input())
u = binpow(n + n + n)
a = 7
v = binpow(n)
print((u + B - v) % B)


from sys import stdin, stdout, stderr

def fast(n, m, mod):
	res = 1
	while m != 0:
		if m & 1:
			res = res * n % mod
		m = m // 2
		n = n * n % mod
	return res
n = int(input())
a = 27
b = 7
print((fast(a, n, 1000000007) - fast(b, n, 1000000007) + 1000000007) % 1000000007)


import sys
from math import *
from itertools import product

def ints_input():
	return [int(i) for i in sys.stdin.readline().strip('\n').split(' ')]

def print_list(arr):
	sys.stdout.writelines((str(x) + ' ' for x in arr))
	sys.stdout.write('\n')

def fast_input(type=str):
	return type(sys.stdin.readline().strip('\n'))
n = fast_input(int)
print(int((3 ** (3 * n) - 7 ** n) % (10 ** 9 + 7)))


from sys import stdin
input = lambda : stdin.readline().strip()
from math import ceil, sqrt, factorial, gcd
from collections import deque
n = int(input())
(a, b) = (1, 1)
mod = 1000000007
a = pow(27, n, mod)
b = pow(7, n, mod)
print((a - b) % mod)


def main():
	n = int(input())
	a = 1
	b = 1
	mod = 10 ** 9 + 7
	for i in range(n):
		a = a * 27 % mod
		b = b * 7 % mod
	print((a - b) % mod)
main()


def mod_exp(a, b, m):
	x = a
	y = 1
	while b > 0:
		if b % 2:
			y = y * x % m
		x = x * x % m
		b = b >> 1
	return y
m = 10 ** 9 + 7
n = int(input())
print((mod_exp(3, 3 * n, m) - mod_exp(7, n, m)) % m)


n = int(input())
number_of_ways = (27 ** n - 7 ** n) % (10 ** 9 + 7)
print(number_of_ways)


x = int(input())
print((27 ** x - 7 ** x) % 1000000007)


gemy = int(input())
print((27 ** gemy - 7 ** gemy) % 1000000007)


n = int(input())
m = 1000000007
ans = 1
ans2 = 1
for i in range(1, n + 1):
	ans = ans * 27
	ans = ans % m
	ans2 = ans2 * 7 % m
ans = ans % m
ans2 = ans2 % m
print((ans - ans2) % m)


n = int(input())
(p, d) = (1, 1)
mod = 10 ** 9 + 7
for i in range(n):
	p *= 27
	d *= 7
	p %= mod
	d %= mod
print(p - d) if p >= d else print(mod + p - d)


import os
import sys
from io import BytesIO, IOBase
import math
from decimal import Decimal
from decimal import *
from collections import defaultdict, deque
import heapq
from decimal import Decimal
getcontext().prec = 25
abcd = 'abcdefghijklmnopqrstuvwxyz'
MOD = pow(10, 9) + 7
BUFSIZE = 8192
from bisect import bisect_left, bisect_right

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def binpow(a, b, m):
	a %= m
	res = 1
	while b > 0:
		if b & 1:
			res = res * a % m
		a = a * a % m
		b >>= 1
	return res
n = int(input())
if n != 1:
	ans = (binpow(3, 3 * n, MOD) - binpow(7, n, MOD)) % MOD
else:
	ans = 20
print(ans)


__author__ = 'User'
n = int(input())
k = 1
s = 1
const = 10 ** 9 + 7
for i in range(n):
	s *= 27
	s = s % const
	k *= 7
	k = k % const
print((s - k) % const)


n = int(input())
MOD = 1000000007
print((pow(27, n, MOD) - pow(7, n, MOD)) % MOD)


n = int(input())
MOD = 1000000007
a = pow(7, n, MOD)
b = pow(3, 3 * n, MOD)
print((b - a) % MOD)


n = int(input())
var1 = pow(27, n, 10 ** 9 + 7)
var2 = pow(7, n, 10 ** 9 + 7)
print((var1 - var2) % (10 ** 9 + 7))


n = int(input())
threepower = 27
sevenpower = 7
count = 1
while count < n:
	threepower = threepower * 27 % (1000000000 + 7)
	sevenpower = sevenpower * 7 % (1000000000 + 7)
	count += 1
answer = threepower - sevenpower
if answer < 0:
	answer += 1000000000 + 7
print(answer)


ans = 0
n = int(input())
k = 3 ** (3 * n)
s = 7 ** n
if n == 1:
	print(20)
else:
	ans = k - s
	print(ans % (10 ** 9 + 7))


n = input()
x = 3 ** (3 * int(n)) - 7 ** int(n)
print(x % 1000000007)


from sys import stdin, stdout
input = stdin.readline
n = int(input())
stdout.write(str((3 ** (3 * n) - 7 ** n) % 1000000007))


MOD = 10 ** 9 + 7

def fast_exp(a, b):
	if b == 0:
		return 1
	elif b % 2 == 0:
		return fast_exp(a * a % MOD, b / 2) % MOD
	else:
		return a * fast_exp(a, b - 1) % MOD
num = int(input())
b = 3 * num
x = fast_exp(3, b)
y = fast_exp(7, num)
result = ((x - y) % MOD + MOD) % MOD
print(result)


n = int(input())
al = 27 ** n
bad = 7 ** n
print((al - bad) % (10 ** 9 + 7))


n = int(input())
a = 1
b = 1
mod = 1000000000.0 + 7
for i in range(3 * n):
	a = a * 3 % mod
for i in range(n):
	b = b * 7 % mod
print(int((a - b + mod) % mod))


n = int(input())
num = pow(3, 3 * n) - pow(7, n)
print(num % (10 ** 9 + 7))


n = int(input())
total = 3 ** (3 * n)
print((total - 7 ** n) % (10 ** 9 + 7))


n = int(input())
gnomes = n * 3
res = (pow(3, gnomes) - pow(7, n)) % (pow(10, 9) + 7)
print(res)


q = int(input())
print((3 ** (3 * q) - 7 ** q) % 1000000007)


N = int(input())
print((pow(27, N) - pow(7, N)) % (1000000000 + 7))


import sys
f = sys.stdin
n = int(f.readline().strip())
rr = 10 ** 9 + 7
ni = 20
nf = 27
for i in range(n - 1):
	ni = 20 * nf + 7 * ni
	nf = 27 * nf
	if ni > rr:
		ni = ni % rr
		nf = nf % rr
print(str(ni % rr))


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = 1
	rr = []
	for _ in range(t):
		n = I()
		rr.append((pow(27, n, mod) - pow(7, n, mod)) % mod)
	return JA(rr, '\n')
print(main())


n = int(input())
p = 27 ** n % 1000000007
c = 7 ** n % 1000000007
print((p - c) % 1000000007)


n = int(input())
s = 3 ** (3 * n) - 7 ** n
print(s % 1000000007)


from math import floor
MOD = 1000000007
n = int(input())
print((27 ** n % MOD - 7 ** n % MOD) % MOD)


n = int(input())
m = 3 * n
mod = 1000000007
cont = 0
cont = 3 ** m - 7 ** n
print(cont % mod)


n = int(input(''))
m = 1000000007
print((3 ** (3 * n) - 7 ** n) % m)


n = int(input())
modulo = 1000000007
res1 = pow(3, 3 * n, modulo)
res2 = pow(7, n, modulo)
res = (res1 - res2) % modulo
print(res)


n = eval(input())
print((3 ** (3 * n) - 7 ** n) % 1000000007)


n = int(input())
md = 10 ** 9 + 7
a = pow(27, n, md)
b = pow(7, n, md)
c = a - b
if c < 0:
	c += md
print(c)


n = int(input())
p = 3 ** (3 * n)
p -= 7 ** n
print(p % (10 ** 9 + 7))


mod = 10 ** 9 + 7

def binpow(x, y):
	global mod
	res = 1
	while y:
		if y & 1:
			res = res * x % mod
		x = x * x % mod
		y >>= 1
	return res
n = int(input())
x = binpow(27, n) - binpow(7, n)
if x < 0:
	x += mod
x %= mod
print(x)


n = int(input())
M = 10 ** 9 + 7
t1 = 0
t2 = 0
for i in range(1, 4):
	for j in range(1, 4):
		for k in range(1, 4):
			if i + j + k == 6:
				t1 += 1
			t2 += 1
a1 = 1
a2 = 1
for i in range(n):
	a1 = a1 * t1 % M
	a2 = a2 * t2 % M
ans = ((a2 - a1) % M + M) % M
print(ans)


n = int(input())
n27 = int(1)
n7 = int(1)
for i in range(n):
	n27 = n27 * int(27)
	n7 = n7 * int(7)
	n27 = n27 % int(1000000000.0 + 7)
	n7 = n7 % int(1000000000.0 + 7)
print(int(n27 - n7) % int(1000000000.0 + 7))


MOD = 1000000007
n = int(input())
a = 27 ** n % MOD
b = 7 ** n % MOD
res = ((a - b) % MOD + MOD) % MOD
print(res)


MOD = int(1000000007)
n = int(input())
all = int(1)
for i in range(3 * n):
	all = 3 * all % MOD
bad = int(1)
for i in range(n):
	bad = 7 * bad % MOD
ans = all - bad
if ans < 0:
	ans += MOD
print(ans)


n = int(input())
bad = 7 ** n
al = 3 ** (3 * n)
print((al - bad) % (10 ** 9 + 7))


import itertools as it
import functools
import operator
import collections
import math
import sys
BIG = 1000000007

def solve(n):
	return (3 ** (3 * n) - (6 + 1) ** n) % BIG

def p(*args, **kwargs):
	return print(*args, file=sys.stderr, **kwargs)

def main():
	n = int(input())
	result = solve(n)
	print(result)
main()


import time
import math
n = int(input())
start = time.time()
M = 1000000000 + 7
ans = 3 ** (3 * n) - 7 ** n
print(divmod(ans, M)[1])
finish = time.time()


import sys
entry = int(sys.stdin.read())
print((3 ** (3 * entry) - 7 ** entry) % (10 ** 9 + 7))


n = int(input())
rem1 = 1
for i in range(3 * n):
	rem1 *= 3
	rem1 = rem1 % (7 + 10 ** 9)
rem2 = 1
for i in range(n):
	rem2 *= 7
	rem2 = rem2 % (7 + 10 ** 9)
ans = (rem1 - rem2) % (7 + 10 ** 9)
print(ans)


x = int(input())
y = 3 ** (3 * x) - 7 ** x
print(y % 1000000007)


import sys, re, math
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest

def STR():
	return list(input())

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST():
	return list(map(int, input().split()))

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def sortListWithIndex(listOfTuples, idx):
	return sorted(listOfTuples, key=lambda x: x[idx])

def sortDictWithVal(passedDic):
	temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))[::-1]
	toret = {}
	for tup in temp:
		toret[tup[0]] = tup[1]
	return toret

def sortDictWithKey(passedDic):
	return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
n = INT()
print((3 ** (3 * n) - 7 ** n) % mod)


def calc(n):
	return (3 ** (3 * n) - 7 ** n) % (10 ** 9 + 7)
n = int(input())
print(calc(n))


def pow(base, exp):
	res = 1
	while exp:
		if exp & 1:
			res *= base
			res %= mod
		base *= base
		base %= mod
		exp = exp >> 1
	return res
n = int(input())
mod = 1000000007
if n == 1:
	print(20)
else:
	res1 = pow(27, n)
	res2 = pow(7, n)
	print((res1 - res2 + mod) % mod)


n = int(input())
mod = 10 ** 9 + 7

def pow_mod(x, a):
	y = 1
	for i in range(a):
		y *= x
		if y > mod:
			y %= mod
	return y
result = pow_mod(27, n) - pow_mod(7, n)
result = (result + mod) % mod
print(result)


n = int(input())
x = pow(3, 3 * n) - pow(7, n)
print(x % (10 ** 9 + 7))


MOD = 10 ** 9 + 7
n = int(input())
ans = 20
seven_degree = 1
for i in range(1, n):
	seven_degree *= 7
	seven_degree %= MOD
	ans = (ans * 27 % MOD + seven_degree * 20) % MOD
print(ans)


def solution():
	n = int(input())
	M = 10 ** 9 + 7
	return rec(n, M)

def rec(n, M):
	if n == 1:
		return 20
	if n % 2 == 1:
		return (27 * rec(n - 1, M) + 20 * 7 ** (n - 1)) % M
	else:
		n = int(n / 2)
		x = rec(n, M)
		return (x ** 2 + 2 * x * 7 ** n) % M
print(solution())


entrada = int(input())
modulo = 1000000007
a = 1
b = 1
for j in range(entrada):
	b = b * 7 % modulo
tamanho = entrada * 3
for i in range(tamanho):
	a = a * 3 % modulo
print((a - b + modulo) % modulo)