#include <bits/stdc++.h>
using namespace std;
const int HH = 4 + (int)1e5 * 2;
int six;
int no_six;
int all;
void sol(int n) {
  long long n27 = 1;
  long long n7 = 1;
  const long long MOD = (int)1e9 + 7;
  for (int i = 0; i < n; i++) {
    n27 = (n27 * 27) % MOD;
    while (n27 < 0) n27 += MOD;
    n7 = (n7 * 7) % MOD;
    while (n7 < 0) n7 += MOD;
  }
  long long ans = (n27 - n7) % MOD;
  while (ans < 0) ans += MOD;
  cout << ans << endl;
}
int main() {
  for (int i = 1; i <= 3; i++)
    for (int j = 1; j <= 3; j++)
      for (int k = 1; k <= 3; k++)
        if (i + j + k != 6) no_six++;
  all = 3 * 3 * 3;
  six = all - no_six;
  int n;
  while (cin >> n) sol(n);
}
