You are given a tetrahedron. Let's mark its vertices with letters A, B, C and D correspondingly.

<image>

An ant is standing in the vertex D of the tetrahedron. The ant is quite active and he wouldn't stay idle. At each moment of time he makes a step from one vertex to another one along some edge of the tetrahedron. The ant just can't stand on one place.

You do not have to do much to solve the problem: your task is to count the number of ways in which the ant can go from the initial vertex D to itself in exactly n steps. In other words, you are asked to find out the number of different cyclic paths with the length of n from vertex D to itself. As the number can be quite large, you should print it modulo 1000000007 (109 + 7). 

Input

The first line contains the only integer n (1 ≤ n ≤ 107) — the required length of the cyclic path.

Output

Print the only integer — the required number of ways modulo 1000000007 (109 + 7).

Examples

Input

2


Output

3


Input

4


Output

21

Note

The required paths in the first sample are: 

  * D - A - D
  * D - B - D
  * D - C - D
from __future__ import print_function
import sys
from collections import deque,defaultdict
import math
import functools
import itertools
from bisect import bisect_left,bisect_right
import operator
import heapq
from random import random,randint,randrange,shuffle
true=True
false=False
null=None
reduce=functools.reduce
SLOW=__debug__
try:
 range=xrange
except:
 pass
def fast():
 global SLOW
 SLOW=False
def compute(val, func): return func(val)
def seq(lo,hi,step=1): 
 return range(lo,hi+1,step)
def sround(val,nd):
 return '{0:.{1}f}'.format(val,nd)
def ceil(a,b):
 ans=a//b
 if a%b!=0: ans+=1
 return ans
def e1e(d,e): return d*(10**e)
mod=e1e(1,9)+7
try:
 memoi=functools.lru_cache(None)
except:
 class memoize(dict):
  def __init__(self,f):
   self.f=f
  def __call__(self,*args):
   return self[args]
  def __missing__(self,key):
   ans=self[key]=self.f(*key)
   return ans
 memoi=memoize
class ndarray(list):
 def __init__(self,defval,sizes):
  self.sizes=sizes
  self.dimension=len(sizes)
  self.pm=pm=list(sizes)
  pm.append(1)
  for ii in reversed(range(self.dimension)): pm[ii]*=pm[ii+1]
  list.__init__(self,[defval]*pm[0])
 def ___i1d___(self,ixs):
  if SLOW:
   assert len(ixs)==self.dimension, ('Dimension must be {}.'.format(self.dimension))
  ans=0
  for ii in range(self.dimension):
   ix=ixs[ii]
   if SLOW:
    assert ix<self.sizes[ii], ('Index[{}]={} >= Len[{}]={}.'.format(ii,ix,ii,self.sizes[ii]))
   ans+=ix*self.pm[ii+1]
  return ans
 def __getitem__(self,ixs):
  ixs=self.___i1d___(ixs)
  return list.__getitem__(self,ixs)
 def __setitem__(self,ixs,val):
  ixs=self.___i1d___(ixs)
  list.__setitem__(self,ixs,val)
 def _str_(self,dim0=0,ofs=0):
  lft="  "*dim0
  if dim0+1==self.dimension: return lft+str(list.__getitem__(self,slice(ofs,ofs+self.sizes[dim0])))
  ans=[]
  for ii in range(self.sizes[dim0]):
   ans.append(self._str_(dim0+1,ofs))
   ofs+=self.pm[dim0+1]
  ans="{0}[\n{1}\n{0}]".format(lft,",\n".join(ans))
  return ans
 def __str__(self):
  return self._str_()
def arrays(defval,*sizes):
 if len(sizes)==1: return [defval]*sizes[0]
 return ndarray(defval,sizes)
def perr(*args,**kwargs): 
 if SLOW:
  print(*args,file=sys.stderr,**kwargs)
def line():
 ln=sys.stdin.readline().strip()
 #perr(ln)
 if ln=='': sys.exit()
 return ln
def lines(n): return [line() for i in range(n)]
def split(ln=None): return (ln or line()).split()
def num(str=None):
 str=str or line()
 return float(str) if '.' in str else int(str)
def nums(o=None):
 if o is not None:
  if isinstance(o, int): o=lines(o)
  elif isinstance(o, str): o=split(o)
 return list(map(num, o or split()))
def loop(f,n=0):
 for tcid in range(n or 99999999): f(tcid+1)
def repeat(n,f):
 for _ in range(n): yield f()
def recursi(root,fchildren,ctop):
  p=deque()
  c=deque()
  q=deque()
  q.append(root)
  while len(q)>0:
   pp=q.popleft()
   for cc in fchildren(pp):
    p.append(pp)
    c.append(cc)
    q.append(cc)
  for _ in range(len(p)):
   ctop(c.pop(),p.pop())   
def summod(*args):
 sums=0
 for vv in args:
  sums=(sums+vv)%mod
 return sums
def multmod(*args):
 ans=0
 for vv in args:
  ans=(ans+vv)%mod
 return ans
def subsmod(*args):
 ans=0
 for vv in args:
  ans=(ans+mod-vv)%mod
 return ans
def matmultmod(a,b):
 ra=len(a)
 ca=len(a[0])
 rb=len(b)
 cb=len(b[0])
 if SLOW:
  assert ca==rb, "matrix incompatible size"
 return [[summod(*map(lambda ii:a[rr][ii]*b[ii][cc],range(ca))) for cc in range(cb)] for rr in range(ra)]
"""
matmultmod()
summod() multmod() subsmod()
recursi(root,fchilds,ctop)
e1e(d,e) mod arrays(defv,*sz) repeat(n,f)
ceil(a,b) sround(val,nd) true false null @memoi
num(?) nums(?) split(?) lines(n) line()
perr(print) seq() loop(f(tcid),0) compute(v,f) fast()
"""
#
def mainloop(tcid): #
 ignored=1 #
 n=num()
 tra=[]
 tra.append((
  (0,1,1,1),
  (1,0,1,1),
  (1,1,0,1),
  (1,1,1,0)))
 for _ in range(30):
  tra.append(matmultmod(tra[-1],tra[-1]))
 def gen(n):
  for ii in range(30):
   if (n&(1<<ii))!=0:
    yield tra[ii]
 bb=reduce(matmultmod,gen(n))
 aa=((1,0,0,0),)
 ans=matmultmod(aa,bb)
 print(ans[0][0])
tcmax=0
loop(mainloop,tcmax) #
#