You are given a tetrahedron. Let's mark its vertices with letters A, B, C and D correspondingly.

<image>

An ant is standing in the vertex D of the tetrahedron. The ant is quite active and he wouldn't stay idle. At each moment of time he makes a step from one vertex to another one along some edge of the tetrahedron. The ant just can't stand on one place.

You do not have to do much to solve the problem: your task is to count the number of ways in which the ant can go from the initial vertex D to itself in exactly n steps. In other words, you are asked to find out the number of different cyclic paths with the length of n from vertex D to itself. As the number can be quite large, you should print it modulo 1000000007 (109 + 7). 

Input

The first line contains the only integer n (1 ≤ n ≤ 107) — the required length of the cyclic path.

Output

Print the only integer — the required number of ways modulo 1000000007 (109 + 7).

Examples

Input

2


Output

3


Input

4


Output

21

Note

The required paths in the first sample are: 

  * D - A - D
  * D - B - D
  * D - C - D
#include <bits/stdc++.h>
using namespace std;
void error(istream_iterator<string> _iterat) {}
template <typename T, typename... args>
void error(istream_iterator<string> _iterat, T a, args... arguments) {
  cerr << *_iterat << "=" << a << "\n";
  error(++_iterat, arguments...);
}
template <typename T, typename V>
void error(string pri, const pair<T, V> &z) {
  cerr << pri << "="
       << "{" << z.first << "," << z.second << "}"
       << "\n";
}
template <typename T, typename V>
void error(string pri, const map<T, V> &z) {
  cerr << pri << " is={";
  for (auto it = z.begin(); it != z.end(); ++it) {
    cerr << it->first << ":" << it->second;
    auto _it = z.end();
    _it--;
    if (it != _it) cerr << ",";
  }
  cerr << "}";
  cerr << "\n";
}
template <typename T>
void error(string pri, const vector<T> &z, long long st, long long ed) {
  cerr << pri << " in range[" << st << "," << ed << ")=[";
  for (long long i = st; i < ed; ++i) {
    cerr << z[i];
    if (i != ed - 1) cerr << " ";
  }
  cerr << "]";
  cerr << "\n";
}
template <typename T>
void error(string pri, const set<T> &z, long long st, long long ed) {
  cerr << pri << " in range[" << st << "," << ed << ")=[";
  long long tempcount = 0;
  for (auto it = z.begin(); it != z.end(); ++it) {
    if (tempcount >= st and tempcount < ed) {
      cerr << *it;
      if (tempcount != ed - 1) cerr << " ";
    }
    tempcount++;
  }
  cerr << "]";
  cerr << "\n";
}
template <typename T>
void error(string pri, const T z[], long long st, long long ed) {
  cerr << pri << " in range[" << st << "," << ed << ")=[";
  for (long long i = st; i < ed; ++i) {
    cerr << z[i];
    if (i != ed - 1) cerr << " ";
  }
  cerr << "]";
  cerr << "\n";
}
const long long s = 4;
const long long mod = pow(10, 9) + 7;
void mul(long long a1[s][s], long long a2[s][s]) {
  long long temp[s][s];
  for (long long i = 0; i < s; ++i) {
    for (long long j = 0; j < s; ++j) {
      temp[i][j] = 0;
      for (long long k = 0; k < s; ++k) {
        temp[i][j] = temp[i][j] % mod + (a1[i][k] % mod * a2[k][j] % mod) % mod;
        temp[i][j] = temp[i][j] % mod;
      }
    }
  }
  for (long long i = 0; i < s; ++i) {
    for (long long j = 0; j < s; ++j) {
      a1[i][j] = temp[i][j] % mod;
    }
  }
}
void power(long long arr[s][s], long long y) {
  long long ans[s][s];
  for (long long i = 0; i < s; ++i) {
    for (long long j = 0; j < s; ++j) {
      if (i == j)
        ans[i][j] = 1;
      else
        ans[i][j] = 0;
    }
  }
  while (y > 0) {
    if (y & 1) mul(ans, arr);
    mul(arr, arr);
    y = y >> 1;
  }
  for (long long i = 0; i < s; ++i) {
    for (long long j = 0; j < s; ++j) {
      arr[i][j] = ans[i][j] % mod;
    }
  }
}
void logic() {
  long long arr[s][s] = {
      {0, 1, 1, 1}, {1, 0, 1, 1}, {1, 1, 0, 1}, {1, 1, 1, 0}};
  long long n;
  cin >> n;
  if (n == 1)
    cout << 0;
  else {
    power(arr, n);
    cout << arr[0][0] % mod;
  }
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  long long t;
  { logic(); }
}
