#include <bits/stdc++.h>
using namespace std;
long long b;
long long shitfuckyou(long long a, long long b, long long n) {
  if (b == 1) return a % n;
  if (b % 2 == 0) {
    long long t = shitfuckyou(a, b / 2, n);
    return t * t % n;
  } else {
    long long t = shitfuckyou(a, b / 2, n);
    t = t * t % n;
    return t * a % n;
  }
}
int main() {
  cin >> b;
  if (b > 1)
    cout << shitfuckyou(2, b - 1, 1000000007) *
                (2 * shitfuckyou(2, b - 1, 1000000007) + 1) % 1000000007
         << endl;
  else if (b == 1)
    cout << 3 << endl;
  else
    cout << 1 << endl;
  return 0;
}
