#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
struct node {
  long long v[5];
  node() {
    v[1] = 3;
    v[2] = 1;
    v[3] = 1;
    v[4] = 3;
  }
  node mul(node t) {
    node p;
    p.v[1] = (v[1] * t.v[1] + v[2] * t.v[3]) % mod;
    p.v[2] = (v[1] * t.v[2] + v[2] * t.v[4]) % mod;
    p.v[3] = (v[3] * t.v[1] + v[4] * t.v[3]) % mod;
    p.v[4] = (v[3] * t.v[2] + v[4] * t.v[4]) % mod;
    return p;
  }
  void print() {
    cout << v[1] << " " << v[2] << endl;
    cout << v[3] << " " << v[4] << endl;
  }
};
node mi(node k, long long n) {
  if (n == 1) return k;
  node t = mi(k, n / 2);
  t = t.mul(t);
  if (n % 2 == 1) t = t.mul(k);
  return t;
}
int main() {
  long long n;
  cin >> n;
  if (n == 0) {
    puts("1");
    return 0;
  }
  node t;
  t = mi(t, n);
  cout << t.v[1] % mod << endl;
}
