#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const int mod = inf + 7;
const double eps = 1e-9;
const double pi = acos(-1.0);
int n, t;
int a[100100], cur = 0, all;
int binpow(int a, int k) {
  if (k == 0) return 1;
  int ans = binpow(a, k / 2);
  ans = 1ll * ans * ans % mod;
  if (k % 2) ans = 1ll * ans * a % mod;
  return ans;
}
int main() {
  cin >> n;
  int bad = 0;
  for (int i = 1; i < 4; i++) {
    for (int j = 1; j < 4; j++) {
      for (int k = 1; k < 4; k++) {
        if (i + j + k == 6) bad++;
      }
    }
  }
  bad = binpow(bad, n);
  all = binpow(3, 3 * n);
  all -= bad;
  all %= mod;
  all += mod;
  all %= mod;
  cout << all << endl;
  return 0;
}
