#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
long long x, y, z, a;
struct matrix {
  long long arr[5][5];
  matrix(long long x) {
    memset(arr, 0, sizeof(arr));
    for (int i = 0; i < 2; i++) {
      arr[i][i] = x;
    }
  }
  friend matrix operator*(matrix s, matrix ss) {
    matrix dp(0);
    for (int i = 0; i < 2; i++) {
      for (int j = 0; j < 2; j++) {
        for (int k = 0; k < 2; k++) {
          (dp.arr[i][j] += s.arr[i][k] * ss.arr[k][j]) %= (1000000007);
        }
      }
    }
    return dp;
  }
};
matrix rip(0), res(1);
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  cin >> x;
  rip.arr[0][0] = rip.arr[1][1] = 3;
  rip.arr[1][0] = rip.arr[0][1] = 1;
  res.arr[0][0] = res.arr[1][1] = 1;
  for (int i = 0; i < 63; i++) {
    if (x & (1LL << i)) {
      res = res * rip;
    }
    rip = rip * rip;
  }
  cout << res.arr[0][0] << endl;
  return 0;
}
