#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:260108864")
using namespace std;
class mx {
 public:
  int d[2][2];
  mx operator*(const mx &a) const {
    mx res;
    for (int i(0); i <= ((int)(2) - 1); ++i)
      for (int j(0); j <= ((int)(2) - 1); ++j) res.d[i][j] = 0;
    for (int i(0); i <= ((int)(2) - 1); ++i)
      for (int j(0); j <= ((int)(2) - 1); ++j)
        for (int q(0); q <= ((int)(2) - 1); ++q) {
          res.d[i][j] =
              (res.d[i][j] + (d[i][q] * 1ll * a.d[q][j]) % 1000000007) %
              1000000007;
        }
    return res;
  }
};
mx binpow(mx &a, long long n) {
  mx res;
  for (int i(0); i <= ((int)(2) - 1); ++i)
    for (int j(0); j <= ((int)(2) - 1); ++j)
      if (i == j)
        res.d[i][j] = 1;
      else
        res.d[i][j] = 0;
  mx pw = a;
  while (n) {
    if (n & 1ll) res = res * pw;
    n >>= 1ll;
    pw = pw * pw;
  }
  return res;
}
int main() {
  long long n;
  cin >> n;
  mx temp;
  temp.d[0][0] = temp.d[1][1] = 3;
  temp.d[0][1] = temp.d[1][0] = 1;
  temp = binpow(temp, n);
  printf("%d\n", temp.d[0][0]);
  return 0;
}
