#include <bits/stdc++.h>
using namespace std;
vector<string> vec_splitter(string s) {
  for (char& c : s) c = c == ',' ? ' ' : c;
  stringstream ss;
  ss << s;
  vector<string> res;
  for (string z; ss >> z; res.push_back(z))
    ;
  return res;
}
void debug_out(vector<string> args, int idx) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, Head H, Tail... T) {
  if (idx > 0) cerr << ", ";
  stringstream ss;
  ss << H;
  cerr << args[idx] << " = " << ss.str();
  debug_out(args, idx + 1, T...);
}
long long int power(long long int b, long long int e) {
  if (e == 0) return 1;
  if (e % 2 == 1)
    return b * power(b * b, (e - 1) / 2);
  else
    return power(b * b, e / 2);
}
long long int power(long long int b, long long int e, long long int m) {
  if (e == 0) return 1;
  if (e % 2 == 1)
    return b * power(((b % m) * (b % m)) % m, (e - 1) / 2, m) % m;
  else
    return power(((b % m) * (b % m)) % m, e / 2, m) % m;
}
int nDig(long long int n) {
  if (n < 0) n *= -1;
  if (n == 0) return 1;
  return floor(log10(n) + 1);
}
const long double pi = acos(-1);
class matrix {
 public:
  long long int n;
  vector<vector<long long int>> val;
  matrix(long long int n = 2);
  matrix operator+(const matrix&) const;
  matrix operator-(const matrix&) const;
  matrix operator*(const matrix&) const;
  matrix& operator=(const matrix& b) {
    val = b.val;
    n = b.n;
    return *this;
  }
  void set(long long int x) {
    for (long long int i = (long long int)0;
         0 < n ? i < (long long int)n : (long long int)n < i;
         0 < n ? ++i : --i) {
      for (long long int j = (long long int)0;
           0 < n ? j < (long long int)n : (long long int)n < j;
           0 < n ? ++j : --j) {
        val[i][j] = x;
      }
    }
  }
  void print() {
    for (long long int i = (long long int)0;
         0 < n ? i < (long long int)n : (long long int)n < i;
         0 < n ? ++i : --i) {
      for (long long int j = (long long int)0;
           0 < n ? j < (long long int)n : (long long int)n < j;
           0 < n ? ++j : --j) {
        cout << val[i][j] << " ";
      }
      cout << '\n';
    }
  }
  matrix mul(long long int a) {
    matrix ans(this->n);
    for (long long int i = (long long int)0;
         0 < this->n ? i < (long long int)this->n : (long long int)this->n < i;
         0 < this->n ? ++i : --i) {
      for (long long int j = (long long int)0;
           0 < this->n ? j < (long long int)this->n
                       : (long long int)this->n < j;
           0 < this->n ? ++j : --j) {
        ans.val[i][j] = a * this->val[i][j];
      }
    }
    return ans;
  }
};
matrix::matrix(long long int x) {
  n = x;
  val.resize(x);
  for (long long int i = (long long int)0;
       0 < x ? i < (long long int)x : (long long int)x < i; 0 < x ? ++i : --i) {
    val[i].resize(x);
  }
}
matrix matrix::operator+(const matrix& b) const {
  matrix ans(b.n);
  for (long long int i = (long long int)0;
       0 < b.n ? i < (long long int)b.n : (long long int)b.n < i;
       0 < b.n ? ++i : --i) {
    for (long long int j = (long long int)0;
         0 < b.n ? j < (long long int)b.n : (long long int)b.n < j;
         0 < b.n ? ++j : --j) {
      ans.val[i][j] = this->val[i][j] + b.val[i][j];
    }
  }
  return ans;
}
matrix matrix::operator-(const matrix& b) const {
  matrix ans(b.n);
  for (long long int i = (long long int)0;
       0 < b.n ? i < (long long int)b.n : (long long int)b.n < i;
       0 < b.n ? ++i : --i) {
    for (long long int j = (long long int)0;
         0 < b.n ? j < (long long int)b.n : (long long int)b.n < j;
         0 < b.n ? ++j : --j) {
      ans.val[i][j] = this->val[i][j] - b.val[i][j];
    }
  }
  return ans;
}
matrix matrix::operator*(const matrix& b) const {
  matrix ans(b.n);
  for (long long int i = (long long int)0;
       0 < b.n ? i < (long long int)b.n : (long long int)b.n < i;
       0 < b.n ? ++i : --i) {
    for (long long int j = (long long int)0;
         0 < b.n ? j < (long long int)b.n : (long long int)b.n < j;
         0 < b.n ? ++j : --j) {
      for (long long int k = (long long int)0;
           0 < b.n ? k < (long long int)b.n : (long long int)b.n < k;
           0 < b.n ? ++k : --k) {
        ans.val[i][j] =
            (ans.val[i][j] + this->val[i][k] * b.val[k][j] % 1000000007) %
            1000000007;
      }
    }
  }
  return ans;
}
matrix identity(long long int N = 2) {
  matrix ans(N);
  for (long long int i = (long long int)0;
       0 < N ? i < (long long int)N : (long long int)N < i; 0 < N ? ++i : --i) {
    ans.val[i][i] = 1;
  }
  return ans;
}
matrix matexpo(matrix a, long long int n) {
  if (n == 0) {
    return identity(a.n);
  }
  if (n == 1) return a;
  matrix x = matexpo(a, n / 2);
  matrix r = x * x;
  if (n & 1) r = r * a;
  return r;
}
void swagWaalaFunction() {
  long long int n;
  cin >> n;
  matrix m(4);
  for (long long int i = 0; i < (long long int)4; ++i)
    for (long long int j = 0; j < (long long int)4; ++j)
      if (i != j) m.val[i][j] = 1;
  m = matexpo(m, n);
  cout << m.val[0][0] % 1000000007;
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int t = 1;
  while (t--) swagWaalaFunction();
  return 0;
}

### Prompt

Please create a solution in Cpp to the following problem:

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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
vector<string> vec_splitter(string s) {
  for (char& c : s) c = c == ',' ? ' ' : c;
  stringstream ss;
  ss << s;
  vector<string> res;
  for (string z; ss >> z; res.push_back(z))
    ;
  return res;
}
void debug_out(vector<string> args, int idx) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, Head H, Tail... T) {
  if (idx > 0) cerr << ", ";
  stringstream ss;
  ss << H;
  cerr << args[idx] << " = " << ss.str();
  debug_out(args, idx + 1, T...);
}
long long int power(long long int b, long long int e) {
  if (e == 0) return 1;
  if (e % 2 == 1)
    return b * power(b * b, (e - 1) / 2);
  else
    return power(b * b, e / 2);
}
long long int power(long long int b, long long int e, long long int m) {
  if (e == 0) return 1;
  if (e % 2 == 1)
    return b * power(((b % m) * (b % m)) % m, (e - 1) / 2, m) % m;
  else
    return power(((b % m) * (b % m)) % m, e / 2, m) % m;
}
int nDig(long long int n) {
  if (n < 0) n *= -1;
  if (n == 0) return 1;
  return floor(log10(n) + 1);
}
const long double pi = acos(-1);
class matrix {
 public:
  long long int n;
  vector<vector<long long int>> val;
  matrix(long long int n = 2);
  matrix operator+(const matrix&) const;
  matrix operator-(const matrix&) const;
  matrix operator*(const matrix&) const;
  matrix& operator=(const matrix& b) {
    val = b.val;
    n = b.n;
    return *this;
  }
  void set(long long int x) {
    for (long long int i = (long long int)0;
         0 < n ? i < (long long int)n : (long long int)n < i;
         0 < n ? ++i : --i) {
      for (long long int j = (long long int)0;
           0 < n ? j < (long long int)n : (long long int)n < j;
           0 < n ? ++j : --j) {
        val[i][j] = x;
      }
    }
  }
  void print() {
    for (long long int i = (long long int)0;
         0 < n ? i < (long long int)n : (long long int)n < i;
         0 < n ? ++i : --i) {
      for (long long int j = (long long int)0;
           0 < n ? j < (long long int)n : (long long int)n < j;
           0 < n ? ++j : --j) {
        cout << val[i][j] << " ";
      }
      cout << '\n';
    }
  }
  matrix mul(long long int a) {
    matrix ans(this->n);
    for (long long int i = (long long int)0;
         0 < this->n ? i < (long long int)this->n : (long long int)this->n < i;
         0 < this->n ? ++i : --i) {
      for (long long int j = (long long int)0;
           0 < this->n ? j < (long long int)this->n
                       : (long long int)this->n < j;
           0 < this->n ? ++j : --j) {
        ans.val[i][j] = a * this->val[i][j];
      }
    }
    return ans;
  }
};
matrix::matrix(long long int x) {
  n = x;
  val.resize(x);
  for (long long int i = (long long int)0;
       0 < x ? i < (long long int)x : (long long int)x < i; 0 < x ? ++i : --i) {
    val[i].resize(x);
  }
}
matrix matrix::operator+(const matrix& b) const {
  matrix ans(b.n);
  for (long long int i = (long long int)0;
       0 < b.n ? i < (long long int)b.n : (long long int)b.n < i;
       0 < b.n ? ++i : --i) {
    for (long long int j = (long long int)0;
         0 < b.n ? j < (long long int)b.n : (long long int)b.n < j;
         0 < b.n ? ++j : --j) {
      ans.val[i][j] = this->val[i][j] + b.val[i][j];
    }
  }
  return ans;
}
matrix matrix::operator-(const matrix& b) const {
  matrix ans(b.n);
  for (long long int i = (long long int)0;
       0 < b.n ? i < (long long int)b.n : (long long int)b.n < i;
       0 < b.n ? ++i : --i) {
    for (long long int j = (long long int)0;
         0 < b.n ? j < (long long int)b.n : (long long int)b.n < j;
         0 < b.n ? ++j : --j) {
      ans.val[i][j] = this->val[i][j] - b.val[i][j];
    }
  }
  return ans;
}
matrix matrix::operator*(const matrix& b) const {
  matrix ans(b.n);
  for (long long int i = (long long int)0;
       0 < b.n ? i < (long long int)b.n : (long long int)b.n < i;
       0 < b.n ? ++i : --i) {
    for (long long int j = (long long int)0;
         0 < b.n ? j < (long long int)b.n : (long long int)b.n < j;
         0 < b.n ? ++j : --j) {
      for (long long int k = (long long int)0;
           0 < b.n ? k < (long long int)b.n : (long long int)b.n < k;
           0 < b.n ? ++k : --k) {
        ans.val[i][j] =
            (ans.val[i][j] + this->val[i][k] * b.val[k][j] % 1000000007) %
            1000000007;
      }
    }
  }
  return ans;
}
matrix identity(long long int N = 2) {
  matrix ans(N);
  for (long long int i = (long long int)0;
       0 < N ? i < (long long int)N : (long long int)N < i; 0 < N ? ++i : --i) {
    ans.val[i][i] = 1;
  }
  return ans;
}
matrix matexpo(matrix a, long long int n) {
  if (n == 0) {
    return identity(a.n);
  }
  if (n == 1) return a;
  matrix x = matexpo(a, n / 2);
  matrix r = x * x;
  if (n & 1) r = r * a;
  return r;
}
void swagWaalaFunction() {
  long long int n;
  cin >> n;
  matrix m(4);
  for (long long int i = 0; i < (long long int)4; ++i)
    for (long long int j = 0; j < (long long int)4; ++j)
      if (i != j) m.val[i][j] = 1;
  m = matexpo(m, n);
  cout << m.val[0][0] % 1000000007;
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int t = 1;
  while (t--) swagWaalaFunction();
  return 0;
}

```