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