#include <bits/stdc++.h>
using namespace std;
long long n, a[3][3], b[3][3], c[3][3];
void f(long long n) {
  while (n) {
    if (n & 1) {
      for (long long i = 1; i <= 2; i++)
        for (long long j = 1; j <= 2; j++) {
          c[i][j] = 0;
          for (long long k = 1; k <= 2; k++)
            c[i][j] += a[i][k] * b[k][j], c[i][j] %= 1000000007;
        }
      for (long long i = 1; i <= 2; i++)
        for (long long j = 1; j <= 2; j++) a[i][j] = c[i][j];
    }
    for (long long i = 1; i <= 2; i++)
      for (long long j = 1; j <= 2; j++) {
        c[i][j] = 0;
        for (long long k = 1; k <= 2; k++)
          c[i][j] += b[i][k] * b[k][j], c[i][j] %= 1000000007;
      }
    for (long long i = 1; i <= 2; i++)
      for (long long j = 1; j <= 2; j++) b[i][j] = c[i][j];
    n /= 2;
  }
}
int main() {
  cin >> n;
  b[1][1] = b[2][2] = 3;
  b[2][1] = b[1][2] = a[1][1] = a[2][2] = 1;
  f(n);
  cout << a[1][1];
}
