#include <bits/stdc++.h>
using namespace std;
long long m, n;
long long check(long long q) {
  long long p = q;
  if (p > 1000000007) p %= 1000000007;
  return p;
}
long long powder(long long p, long long k) {
  if (k == 1) return p;
  if (k == 0) return 1;
  long long q = k;
  long long h = check(powder(p, q / 2) * powder(p, q / 2));
  h = check(h);
  if (q % 2 == 1) h *= powder(p, 1);
  h = check(h);
  return h;
}
int main() {
  cin >> n;
  if (n == 0) {
    cout << 1;
    return 0;
  }
  if (n == 1) {
    cout << 3;
    return 0;
  }
  m = check(powder(2, n - 1));
  n = check(powder(2, n) + 1);
  m = check(m * n);
  cout << m;
}
