#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
template <typename T>
inline bool remin(T& c, const T& n) {
  if (n < c) {
    c = n;
    return 1;
  }
  return 0;
}
template <typename T>
inline bool remax(T& c, const T& n) {
  if (c < n) {
    c = n;
    return 1;
  }
  return 0;
}
template <typename T>
inline void addmod(T& c, const T& n, const T& m) {
  c = (c + n) % m;
}
int _in;
int in() {
  scanf("%d", &_in);
  return _in;
}
const long long mod = 1000000007;
inline pair<pair<long long, long long>, pair<long long, long long> > mult(
    const pair<pair<long long, long long>, pair<long long, long long> >& one,
    const pair<pair<long long, long long>, pair<long long, long long> >& two) {
  return pair<pair<long long, long long>, pair<long long, long long> >(
      pair<long long, long long>((one.first.first * two.first.first +
                                  one.first.second * two.second.first) %
                                     mod,
                                 (one.first.first * two.first.second +
                                  one.first.second * two.second.second) %
                                     mod),
      pair<long long, long long>((one.second.first * two.first.first +
                                  one.second.second * two.second.first) %
                                     mod,
                                 (one.second.first * two.first.second +
                                  one.second.second * two.second.second) %
                                     mod));
}
pair<pair<long long, long long>, pair<long long, long long> > rise(
    pair<pair<long long, long long>, pair<long long, long long> > q,
    long long power) {
  assert(power != 0);
  if (power == 1) return q;
  pair<pair<long long, long long>, pair<long long, long long> > tmp =
      rise(q, power / 2);
  tmp = mult(tmp, tmp);
  if (power % 2 != 0) tmp = mult(tmp, q);
  return tmp;
}
int main() {
  long long p, i;
  scanf("%I64d", &p);
  if (p == 0)
    puts("1");
  else {
    pair<pair<long long, long long>, pair<long long, long long> > q = rise(
        pair<pair<long long, long long>, pair<long long, long long> >(
            pair<long long, long long>(3, 1), pair<long long, long long>(1, 3)),
        p);
    printf("%I64d\n", q.first);
  }
  return 0;
}
