#include <bits/stdc++.h>
using namespace std;
long long matrix[2][2], tmp[2][2];
long long temp[2][2];
void matrixMultiply(long long a[][2], long long b[][2]) {
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++) {
      temp[i][j] = 0;
      for (int k = 0; k < 2; k++)
        temp[i][j] = (temp[i][j] + a[i][k] * b[k][j] + 1000000007) % 1000000007;
    }
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++) a[i][j] = temp[i][j];
}
void solve(long long n) {
  tmp[0][0] = 6;
  tmp[0][1] = -8;
  tmp[1][0] = 1;
  tmp[1][1] = 0;
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++) matrix[i][j] = (i == j);
  while (n) {
    if (n & 1) matrixMultiply(matrix, tmp);
    matrixMultiply(tmp, tmp);
    n >>= 1;
  }
}
int main() {
  long long n;
  cin >> n;
  if (n == 0) {
    cout << 1 << endl;
    return 0;
  }
  if (n == 1) {
    cout << 3 << endl;
    return 0;
  }
  solve(n - 1);
  cout << (matrix[0][0] * 3 + matrix[0][1] + 1000000007) % 1000000007 << endl;
  return 0;
}
