#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  if (n == 0)
    cout << "1" << endl;
  else {
    long long vys = 1ll;
    long long a = 2;
    n--;
    while (n != 0) {
      if (n % 2ll == 1ll) {
        vys *= a;
        vys %= 1000000007ll;
      }
      n /= 2ll;
      a *= a;
      a %= 1000000007ll;
    }
    vys *= (vys * 2ll + 1);
    vys %= 1000000007ll;
    cout << vys << endl;
  }
  return 0;
}
