#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007LL, INF = 1e9, LINF = 1e18;
const long double Pi = 3.141592653589793116, EPS = 1e-9;
const long long dx[4] = {0, 1, 0, -1};
const long long dy[4] = {1, 0, -1, 0};
const long long K = 2;
clock_t time_p = clock();
void time() {
  time_p = clock() - time_p;
  cerr << "Time Taken : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}
vector<vector<long long>> mul(vector<vector<long long>> A,
                              vector<vector<long long>> B) {
  vector<vector<long long>> C(K + 1, vector<long long>(K + 1));
  for (long long i = 1; i < K + 1; i++)
    for (long long j = 1; j < K + 1; j++)
      for (long long k = 1; k < K + 1; k++)
        C[i][j] =
            (C[i][j] % MOD + A[i][k] % MOD * B[k][j] % MOD + INF * MOD) % MOD;
  return C;
}
vector<vector<long long>> pow(vector<vector<long long>> base, long long p) {
  vector<vector<long long>> ans(K + 1, vector<long long>(K + 1));
  long long i, j;
  for (long long i = 1; i < K + 1; i++)
    for (long long j = 1; j < K + 1; j++) ans[i][j] = (i == j);
  while (p) {
    if (p & 1) ans = mul(ans, base);
    base = mul(base, base);
    p >>= 1;
  }
  return ans;
}
long long fun(long long N) {
  vector<long long> F1(K + 1);
  F1[1] = 1;
  F1[2] = 3;
  vector<vector<long long>> T(K + 1, vector<long long>(K + 1));
  T[1][1] = 0, T[1][2] = 1;
  T[2][1] = -8, T[2][2] = 6;
  if (N == 1) return 1;
  if (N == 2) return 3;
  T = pow(T, N - 1);
  long long res = 0;
  for (long long i = 1; i < K + 1; i++)
    res = (res % MOD + T[1][i] % MOD * F1[i] % MOD + INF * MOD) % MOD;
  return res % MOD;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  cout << fun(n + 1) % MOD << "\n";
  time();
  return 0;
}
