mod = 10 ** 9 + 7 range64 = range(64) def mat_mul(l, r): ret = [[0] * 64 for _ in range64] for i in range64: reti = ret[i] li = l[i] for k in range64: lik = li[k] rk = r[k] for j in range64: reti[j] += lik * rk[j] for j in range64: if reti[j] > mod: reti[j] %= mod return ret def mat_pow(A, m): B = [[0] * 64 for _ in range64] for i in range64: B[i][i] = 1 while m: if m & 1: B = mat_mul(B, A) A = mat_mul(A, A) m >>= 1 return B def solve(n): mat = [[0] * 64 for _ in range64] b3 = 8 for i in range(b3): i0 = (i & 1) != 0 i1 = (i & 2) != 0 i2 = (i & 4) != 0 for j in range(b3): j0 = (j & 1) != 0 j1 = (j & 2) != 0 j2 = (j & 4) != 0 fr = (j << 3) | i for p0 in range(2): if i0 and p0: continue if not j0 and not p0: continue for p1 in range(2): if i1 and p1: continue if not j1 and not p1: continue for p2 in range(2): if i2 and p2: continue if not j2 and not p2: continue if (i0 | p0) == 0 and (i1 | p1) == 0: continue if (i2 | p2) == 0 and (i1 | p1) == 0: continue y = (p2 << 2) + (p1 << 1) + p0 x = y | i to = (x << 3) | y mat[fr][to] += 1 if not i0 and not i1: if i2: x = 3 + (1 << 2) y = 0 + (0 << 2) to = (x << 3) | y mat[fr][to] += 1 elif j2: for p2 in range(2): x = 3 + (p2 << 2) y = 0 + (p2 << 2) to = (x << 3) | y mat[fr][to] += 1 else: x = 3 + (1 << 2) y = 0 + (1 << 2) to = (x << 3) | y mat[fr][to] += 1 if not i1 and not i2: if i0: x = 6 + (1 << 0) y = 0 + (0 << 0) to = (x << 3) | y mat[fr][to] += 1 elif j0: for p2 in range(2): x = 6 + (p2 << 0) y = 0 + (p2 << 0) to = (x << 3) | y mat[fr][to] += 1 else: x = 6 + (1 << 0) y = 0 + (1 << 0) to = (x << 3) | y mat[fr][to] += 1 mat = mat_pow(mat, n) ans = 0 for j in range(2, b3): if j == 4: continue fr = j << 3 ans += mat[0b111000][fr] return ans % mod print(solve(int(input())))