#include <bits/stdc++.h>
using namespace std;
const int module = 1000000007;
long long n;
vector<vector<long long> > mul(vector<vector<long long> > a,
                               vector<vector<long long> > b) {
  vector<vector<long long> > c;
  c.resize(2);
  for (long i = 0; i <= 1; i++) {
    c[i].resize(2);
    for (long j = 0; j <= 1; j++) {
      c[i][j] = 0;
      for (long k = 0; k <= 1; k++) c[i][j] = c[i][j] + a[i][k] * b[k][j];
      c[i][j] = c[i][j] % module;
    }
  }
  return c;
}
vector<vector<long long> > power(vector<vector<long long> > m, long long n) {
  if (n == 1) return m;
  vector<vector<long long> > temp = power(m, n / 2);
  temp = mul(temp, temp);
  if (n % 2 == 1) {
    temp = mul(temp, m);
  }
  return temp;
}
int main() {
  vector<vector<long long> > mm;
  cin >> n;
  mm.resize(2);
  mm[0].resize(2);
  mm[1].resize(2);
  mm[0][0] = mm[1][1] = 3;
  mm[0][1] = mm[1][0] = 1;
  if (n == 0) {
    cout << 1;
    return 0;
  }
  mm = power(mm, n);
  cout << mm[0][0];
}
