#include using namespace std; #define rep(i,a,b) for(int i=int(a);i, 64>; Mat matMul(const Mat &l, const Mat &r) { Mat ret {}; for (int i = 0; i < 64; i++) { for (int k = 0; k < 64; k++) { for (int j = 0; j < 64; j++) { (ret[i][j] += (l[i][k] * r[k][j]) % mod + mod) %= mod; } } } return ret; } Mat matPow(Mat A, int64_t m) { Mat B {}; rep(i, 0, 64) B[i][i] = 1; while (m > 0) { if (m & 1) B = matMul(B, A); A = matMul(A, A); m >>= 1; } return B; } int main() { int64_t n; cin >> n; Mat mat {}; int b3 = 1 << 3; rep(i, 0, b3) { bool i0 = (i & 1) != 0; bool i1 = (i & 2) != 0; bool i2 = (i & 4) != 0; rep(j, 0, b3) { bool j0 = (j & 1) != 0; bool j1 = (j & 2) != 0; bool j2 = (j & 4) != 0; int from = (j << 3) | i; rep(p0, 0, 2) { if (i0 && p0) continue; if (!j0 && !p0) continue; rep(p1, 0, 2) { if (i1 && p1) continue; if (!j1 && !p1) continue; rep(p2, 0, 2) { if (i2 && p2) continue; if (!j2 && !p2) continue; if ((i0 | p0) == 0 && (i1 | p1) == 0) continue; if ((i2 | p2) == 0 && (i1 | p1) == 0) continue; int y = (p2 << 2) + (p1 << 1) + p0; int x = y | i; int to = (x << 3) | y; mat[from][to]++; } } } if (!i0 && !i1) { if (i2) { int x = 3 + (1 << 2); int y = 0 + (0 << 2); int to = (x << 3) | y; mat[from][to]++; } else if (j2) { rep(p2, 0, 2) { int x = 3 + (p2 << 2); int y = 0 + (p2 << 2); int to = (x << 3) | y; mat[from][to]++; } } else { int x = 3 + (1 << 2); int y = 0 + (1 << 2); int to = (x << 3) | y; mat[from][to]++; } } if (!i1 && !i2) { if (i0) { int x = 6 + (1 << 0); int y = 0 + (0 << 0); int to = (x << 3) | y; mat[from][to]++; } else if (j0) { rep(p2, 0, 2) { int x = 6 + (p2 << 0); int y = 0 + (p2 << 0); int to = (x << 3) | y; mat[from][to]++; } } else { int x = 6 + (1 << 0); int y = 0 + (1 << 0); int to = (x << 3) | y; mat[from][to]++; } } } } mat = matPow(mat, n); int64_t ans = 0; rep(j, 2, b3) { if (j == 4) continue; int from = j << 3; (ans += mat[0b111000][from]) %= mod; } cout << ans << endl; return 0; }