#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, ans = 1, x = 2;
  scanf("%I64d", &n);
  if (n == 0) {
    printf("1");
    return 0;
  }
  if (n == 1) {
    printf("3");
    return 0;
  }
  n = n - 1;
  while (n) {
    if (n % 2 == 1) {
      ans = (ans * x) % 1000000007;
    }
    x = (x * x) % 1000000007;
    n = n / 2;
  }
  printf("%I64d",
         (ans * ((ans * 2) % 1000000007 + 1) % 1000000007) % 1000000007);
  return 0;
}
