#include <bits/stdc++.h>
using namespace std;
const uint64_t mod = 1e9 + 7;
uint64_t expo(uint64_t a, uint64_t b) {
  if (!b) return 1LL;
  uint64_t t = expo(a, b / 2) % mod;
  if (b % 2) return (((a * t) % mod) * t) % mod;
  return (t * t) % mod;
}
int main() {
  uint64_t n;
  cin >> n;
  if (n == 0)
    cout << 1 << "\n";
  else {
    uint64_t a, b, c;
    a = 3LL * expo(2LL, n - 1LL), b = expo(2LL, 2LL * n - 1LL),
    c = expo(2LL, n);
    uint64_t ans = (((a % mod + b % mod) % mod - c % mod + mod) % mod) % mod;
    cout << ans << "\n";
  }
}
