local mod = 1000000007 local mfl = math.floor local function bmul(x, y) local x1, y1 = mfl(x / 31623), mfl(y / 31623) local x0, y0 = x - x1 * 31623, y - y1 * 31623 return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod end local function badd(x, y) return (x + y) % mod end local ffi = require("ffi") local C = ffi.C ffi.cdef[[ long long atoll(const char*); ]] local function lltonumber(str) return C.atoll(str) end local n = io.read() n = lltonumber(n) mat = {0, 1, 3, 2} ret = {1, 0, 1, 0} while 0LL < n do if n % 2LL == 1LL then local a = badd(bmul(ret[1], mat[1]), bmul(ret[2], mat[3])) local b = badd(bmul(ret[1], mat[2]), bmul(ret[2], mat[4])) local c = badd(bmul(ret[3], mat[1]), bmul(ret[4], mat[3])) local d = badd(bmul(ret[3], mat[2]), bmul(ret[4], mat[4])) ret[1], ret[2], ret[3], ret[4] = a, b, c, d end do local a = badd(bmul(mat[1], mat[1]), bmul(mat[2], mat[3])) local b = badd(bmul(mat[1], mat[2]), bmul(mat[2], mat[4])) local c = badd(bmul(mat[3], mat[1]), bmul(mat[4], mat[3])) local d = badd(bmul(mat[3], mat[2]), bmul(mat[4], mat[4])) mat[1], mat[2], mat[3], mat[4] = a, b, c, d end n = n / 2LL end print(ret[1])