print((function (f, g) local D=1000000007LL return tonumber((f(10,g(),D)*4%D-1)%D*f(3,D-2,D)%D) end)(function (n, p, m) local r=1 while p>0 do if p%2==1 then r=r*n%m end n,p = n*n%m,p/2 end return r end,(function (ffi) ffi.cdef 'int scanf(const char *, ...);' local C,c = ffi.C,ffi.new("long[1]") return function () C.scanf("%ld",c) return c[0] end end)(require'ffi')))