#include <bits/stdc++.h>
using namespace std;
struct Mat {
  int n, m;
  long long mat[5][5];
  Mat() { memset(mat, 0, sizeof(mat)); };
};
Mat operator*(Mat a, Mat b) {
  Mat c;
  c = Mat();
  c.n = a.n, c.m = b.m;
  for (int i = 1; i <= a.n; i++) {
    for (int j = 1; j <= b.m; j++) {
      for (int k = 1; k <= a.m; k++) {
        c.mat[i][j] = (c.mat[i][j] + a.mat[i][k] * b.mat[k][j]) % 1000000007;
      }
    }
  }
  return c;
}
Mat operator^(Mat a, long long k) {
  Mat c;
  int i, j;
  c = Mat();
  c.n = a.n, c.m = a.n;
  for (i = 1; i <= a.n; i++) c.mat[i][i] = 1;
  while (k) {
    if (k & 1) {
      c = c * a;
    }
    a = a * a;
    k >>= 1;
  }
  return c;
}
int main() {
  long long n;
  cin >> n;
  Mat a, b;
  a.n = 1, a.m = 2;
  b.n = 2, b.m = 2;
  a.mat[1][1] = 1, a.mat[1][2] = 0;
  b.mat[1][1] = 3, b.mat[1][2] = 1;
  b.mat[2][1] = 1, b.mat[2][2] = 3;
  a = a * (b ^ n);
  cout << a.mat[1][1] % 1000000007 << endl;
  return 0;
}
