#include <bits/stdc++.h>
using namespace std;
void multiply(vector<vector<long long int>> &a,
              vector<vector<long long int>> &b) {
  vector<vector<long long int>> mul(a.size(),
                                    vector<long long int>(a[0].size(), 0));
  for (long long int i = 0; i < a.size(); i++) {
    for (long long int j = 0; j < b[0].size(); j++) {
      for (long long int k = 0; k < a[0].size(); k++) {
        mul[i][j] =
            ((mul[i][j] % 1000000007) +
             ((a[i][k] % 1000000007) * (b[k][j] % 1000000007)) % 1000000007) %
            1000000007;
      }
    }
  }
  for (long long int i = 0; i < a.size(); i++) {
    for (long long int j = 0; j < a[0].size(); j++) {
      a[i][j] = (mul[i][j] + 1000000007) % 1000000007;
    }
  }
}
void power(vector<vector<long long int>> &a, long long int n,
           vector<vector<long long int>> &b) {
  if (n <= 1) return;
  power(a, n / 2, b);
  multiply(a, a);
  if (n % 2 == 1) multiply(a, b);
}
int main() {
  vector<vector<long long int>> a{{3, 1}, {1, 3}}, b{{3, 1}, {1, 3}};
  long long int N;
  cin >> N;
  if (N == 0) {
    cout << "1" << endl;
    return 0;
  }
  power(a, N, b);
  cout << a[0][0] << endl;
  return 0;
}
