#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

static const int MAX = 100;
const int MOD = 1e+9 + 7;
int n;
map<string, ll> memo[MAX];

bool ok(string last4){
    for(int i = 0; i < 4; i++){
        string t = last4;
        if(i >= 1){
            swap(t[i-1], t[i]);
        }
        if(t.find("AGC") != string::npos){
            return false;
        }
    }
    return true;
}

ll dfs(int i, string last3){
    if(memo[i].count(last3))
        return memo[i][last3];
    if(i == n)
        return 1;
    ll ret = 0;
    for (char c : {'A', 'C', 'G', 'T'}) {
        string last4 = last3 + c;
        if(ok(last4)){
            ret = (ret + dfs(i+1, last4.substr(1, 3))) % MOD;
        }
    }
    memo[i][last3] = ret;
    return ret;
}

int main(){
    cin >> n;
    cout << dfs(0, "TTT") << endl;
    return 0;
}
### Prompt

Construct a Cpp code solution to the problem outlined:

You are given an integer N. Find the number of strings of length N that satisfy the following conditions, modulo 10^9+7:

* The string does not contain characters other than `A`, `C`, `G` and `T`.
* The string does not contain `AGC` as a substring.
* The condition above cannot be violated by swapping two adjacent characters once.

Constraints

* 3 \leq N \leq 100

Input

Input is given from Standard Input in the following format:


N


Output

Print the number of strings of length N that satisfy the following conditions, modulo 10^9+7.

Examples

Input

3


Output

61


Input

4


Output

230


Input

100


Output

388130742

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

static const int MAX = 100;
const int MOD = 1e+9 + 7;
int n;
map<string, ll> memo[MAX];

bool ok(string last4){
    for(int i = 0; i < 4; i++){
        string t = last4;
        if(i >= 1){
            swap(t[i-1], t[i]);
        }
        if(t.find("AGC") != string::npos){
            return false;
        }
    }
    return true;
}

ll dfs(int i, string last3){
    if(memo[i].count(last3))
        return memo[i][last3];
    if(i == n)
        return 1;
    ll ret = 0;
    for (char c : {'A', 'C', 'G', 'T'}) {
        string last4 = last3 + c;
        if(ok(last4)){
            ret = (ret + dfs(i+1, last4.substr(1, 3))) % MOD;
        }
    }
    memo[i][last3] = ret;
    return ret;
}

int main(){
    cin >> n;
    cout << dfs(0, "TTT") << endl;
    return 0;
}
```