#include <bits/stdc++.h>
int main() {
  long long int a, b, c, d = 1, i, j, k = 1, p, q, s = 1000000007, sum = 0;
  long long int x[100], y[100];
  scanf("%lld", &a);
  x[0] = 1;
  y[0] = 2;
  if (a == 0) {
    printf("1");
    return 0;
  }
  for (i = 1; i <= 62; i++) {
    k = k * 2;
    y[i] = (y[i - 1] * y[i - 1]) % s;
    x[i] = k;
  }
  while (1) {
    b = logb(a);
    a = a - x[b];
    d = (d * y[b]) % s;
    if (a <= 0) break;
  }
  sum = ((d % s) * ((d + 1) % s));
  sum = sum / 2;
  printf("%lld", (sum) % s);
  return 0;
}
