#include <bits/stdc++.h>
using namespace std;
long long x, y;
template <class T>
inline T gcd(T a, T b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
template <class T>
inline T lcm(T a, T b) {
  return a * b / gcd(a, b);
}
template <class T>
inline T extended_euclid_returning_gcd(T a, T b) {
  T t, d;
  if (b == 0) {
    d = a;
    x = 1;
    y = 0;
  } else {
    extended_euclid_returning_gcd(b, a % b);
    t = x;
    x = y;
    y = t - (a * y / b);
  }
}
template <class T>
inline T absolute(T a) {
  if (a > 0)
    return a;
  else
    return -a;
}
template <class T>
inline T reverse_num(T a) {
  T x = 0, tmp = a;
  while (tmp) {
    x = 10 * x + tmp % 10;
    tmp /= 10;
  }
  return x;
}
template <class T>
inline T big_mod(T base, T power) {
  T res = 1;
  while (power) {
    if (power & 1) {
      res *= base;
      power--;
    }
    base = base * base;
    power /= 2;
  }
  return res;
}
struct matrix {
  long long value[3][3];
  long long row, col;
};
matrix multiply(matrix &a, matrix &b) {
  matrix ret;
  ret.row = a.row;
  ret.col = b.col;
  long long sum;
  for (int i = 0; i < ret.row; i++) {
    for (int j = 0; j < ret.col; j++) {
      sum = 0;
      for (int k = 0; k < a.col; k++) {
        sum += ((a.value[i][k] % 1000000007) * (b.value[k][j] % 1000000007)) %
               1000000007;
        sum %= 1000000007;
      }
      ret.value[i][j] = sum;
    }
  }
  return ret;
}
matrix matrixExpo(matrix &a, long long p) {
  matrix result;
  result.row = a.row;
  result.col = a.col;
  for (int i = 0; i < result.row; i++) {
    for (int j = 0; j < result.col; j++) {
      if (i == j)
        result.value[i][i] = 1;
      else
        result.value[i][j] = 0;
    }
  }
  while (p) {
    if (p & 1) {
      result = multiply(result, a);
      p--;
    }
    a = multiply(a, a);
    p /= 2;
  }
  return result;
}
int main() {
  long long n;
  matrix a, ans;
  while (cin >> n) {
    a.row = 2;
    a.col = 2;
    a.value[0][0] = a.value[1][1] = 3;
    a.value[0][1] = a.value[1][0] = 1;
    ans = matrixExpo(a, n);
    cout << ans.value[0][0] << endl;
  }
  return 0;
}
