#include #include using namespace std; using LL = long long; using P = pair; using Graph = vector>; const int INF = 1 << 29; const long long LINF = 1LL << 60; #define all(x) (x).begin(), (x).end() #define rep(i,n) for(int i = 0; i < (n); ++i) templatevoid chmin(T&a, T b){if(a > b) a = b;} templatevoid chmax(T&a, T b){if(a < b) a = b;} int main(){ long long N; cin >> N; vector> dp(2, vector(4, 0)); dp[0][0] = 1; for(long long i = 0; i < N; ++i){ for(int j = 0; j < 4; ++j){ dp[(i+1)%2][j] = dp[(i%2)][(j+1)%4] + dp[(i%2)][(j+2)%4] + dp[(i%2)][(j+3)%4]; dp[(i+1)%2][j] %= 1000000007; //cout << dp[(i%2)][j] << " "; } //cout << endl; } cout << dp[N%2][0] << endl; }