#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
const int ff = 0x3f3f3f3f;
struct matrix {
  long long a[5][5];
};
long long n;
matrix in;
matrix multi(matrix x, matrix y) {
  matrix c;
  memset(c.a, 0, sizeof(c.a));
  for (int i = 1; i <= 2; i++)
    for (int j = 1; j <= 2; j++)
      for (int k = 1; k <= 2; k++)
        c.a[i][j] =
            (c.a[i][j] + (x.a[i][k] * y.a[k][j]) % 1000000007) % 1000000007;
  return c;
}
matrix quick_pow(matrix x, long long y) {
  matrix ans = x;
  while (y) {
    if (y & 1) ans = multi(ans, x);
    y >>= 1;
    x = multi(x, x);
  }
  return ans;
}
int main() {
  cin >> n;
  if (n == 1 || n == 0) {
    n = n == 1 ? 3 : 1;
    cout << n << endl;
    return 0;
  }
  in.a[1][1] = in.a[2][2] = 3;
  in.a[1][2] = in.a[2][1] = 1;
  matrix ans = quick_pow(in, n - 2);
  cout << (ans.a[1][1] * 3 + ans.a[1][2]) % 1000000007 << endl;
  return 0;
}
