#include <bits/stdc++.h>
using namespace std;
const int M = 1000000007;
vector<vector<int> > mul(const vector<vector<int> > &a,
                         const vector<vector<int> > &b) {
  vector<vector<int> > c(a.size(), vector<int>(b[0].size(), 0));
  for (int k = 0; k < b.size(); ++k)
    for (int i = 0; i < a.size(); ++i)
      for (int j = 0; j < b[0].size(); ++j)
        c[i][j] = (c[i][j] + (long long)a[i][k] * b[k][j]) % M;
  return c;
}
vector<vector<int> > Pow(const vector<vector<int> > &b, long long p) {
  if (p == 1) return b;
  vector<vector<int> > z = Pow(b, p / 2);
  z = mul(z, z);
  if (p & 1) z = mul(z, b);
  return z;
}
long long n;
int main() {
  scanf("%lld", &n);
  if (n == 0) return puts("1"), 0;
  vector<vector<int> > x(2, vector<int>(2, 0));
  x[0][0] = 3;
  x[0][1] = 1;
  x[1][0] = 1;
  x[1][1] = 3;
  x = Pow(x, n);
  printf("%d", x[0][0]);
  return 0;
}
