#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
long long a, b, m, n, r;
long long f(long long a) {
  if (a == 0) return 1;
  if (a == 1) return 2;
  return ((f(a / 2) * f(a / 2) % mod) * (a & 1 ? 2 : 1)) % mod;
}
int main() {
  cin >> n;
  if (n == 0) {
    cout << 1 << endl;
    return 0;
  }
  cout << (f(n - 1) * (1 + f(n))) % mod << endl;
  return 0;
}
