#include <bits/stdc++.h>
using namespace std;
const long long M = 1000000007;
struct matrix {
  long long a[2][2];
};
matrix f;
long long n;
void mul(matrix a, matrix b, matrix &c) {
  memset(c.a, 0, sizeof(c.a));
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++)
      for (int k = 0; k < 2; k++)
        c.a[i][j] = (c.a[i][j] + a.a[i][k] * b.a[k][j]) % M;
}
matrix power(matrix a, long long b) {
  matrix ret;
  bool first = 1;
  while (b) {
    if (b & 1)
      if (first) {
        ret = a;
        first = 0;
      } else
        mul(ret, a, ret);
    b >>= 1;
    mul(a, a, a);
  }
  return ret;
}
int main() {
  cin >> n;
  if (n == 0)
    cout << 1 << endl;
  else {
    f.a[0][0] = f.a[1][1] = 3;
    f.a[0][1] = f.a[1][0] = 1;
    f = power(f, n);
    cout << f.a[0][0] << endl;
  }
  return 0;
}
