#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000 * 1000 * 1000 + 7;
long long power(long long a, int n, long long mod) {
  long long r = 1;
  while (n) {
    if (n % 2 == 0) {
      a = a * a % mod;
      n /= 2;
    } else {
      r = r * a % mod;
      --n;
    }
  }
  return r;
}
int main() {
  int n;
  std::cin >> n;
  long long total = power(3, 3 * n, mod);
  long long bad = mod - power(27 - 20, n, mod);
  long long good = (bad + total) % mod;
  cout << good;
}
