#!/usr/bin/ python3.8 import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import itertools import numpy as np MOD = 10 ** 9 + 7 # 0: empty, 1~: RULD def cnt_mat(i, j): x1, y1, z1 = i % 5, (i // 5) % 5, i // 25 x2, y2, z2 = j % 5, (j // 5) % 5, j // 25 # 2つ連続の空マスは許容しない if any(s == t == 0 for s, t in ((x1, x2), (y1, y2), (z1, z2), (x1, y1), (y1, z1), (x2, y2), (y2, z2))): return 0 # 貼り合わせ右 if any(s == 1 and t != 3 for s, t in ((x1, x2), (y1, y2), (z1, z2))): return 0 # 貼り合わせ左 if any(s == 3 and t != 1 for s, t in ((x2, x1), (y2, y1), (z2, z1))): return 0 # 貼り合わせ下 if any(s == 4 and t != 2 for s, t in ((x1, y1), (y1, z1), (x2, y2), (y2, z2))): return 0 # 貼り合わせ上 if any(s != 4 and t == 2 for s, t in ((x1, y1), (y1, z1), (x2, y2), (y2, z2))): return 0 # はみ出し if x1 == 2 or x2 == 2 or z1 == 4 or z2 == 4: return 0 return 1 mat = np.zeros((125, 125), np.int64) for i, j in itertools.product(range(125), repeat=2): mat[i, j] = cnt_mat(i, j) def mat_mul(A, B): mask = (1 << 15) - 1 A1 = A >> 15 A2 = A & mask B1 = B >> 15 B2 = B & mask X = np.dot(A1, B1) % MOD Y = np.dot(A2, B2) % MOD Z = (np.dot(A1 + A2, B1 + B2) - X - Y) % MOD W = (np.dot(A1, B2) + np.dot(A2, B1)) % MOD return ((X << 30) + (Z << 15) + Y) % MOD def power(A, n): if n == 1: return A B = power(A, n // 2) B = mat_mul(B, B) return mat_mul(A, B) if n & 1 else B N = int(read()) init = 93 A = power(mat, N)[init, :] answer = 0 for i in range(125): x, y, z = i % 5, (i // 5) % 5, i // 25 if x != 1 and y != 1 and z != 1 and A[i] != 0: answer += A[i] answer %= MOD print(answer)