#include <bits/stdc++.h>
using namespace std;
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-8;
const long long mod = 1000000007;
void Open() {}
long long fac[100010], inv[100010];
long long n;
long long pow_mod(long long x, long long k, long long mod) {
  int res = 1;
  while (k) {
    if (k & 1) res = res * x % mod;
    x = x * x % mod;
    k >>= 1;
  }
  return res;
}
long long get(int x) {
  return fac[n] * inv[x] % mod * inv[n - x] % mod * pow_mod(20, x, mod) % mod *
         pow_mod(27, n - x, mod);
}
int main() {
  scanf("%I64d", &n);
  fac[0] = 1, inv[0] = pow_mod(fac[0], mod - 2, mod);
  for (int i = 1; i <= n; i++)
    fac[i] = fac[i - 1] * i % mod, inv[i] = pow_mod(fac[i], mod - 2, mod);
  long long mul = -1;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    mul *= -1;
    ans = (ans + mul * get(i) % mod) % mod;
  }
  printf("%I64d\n", (ans + mod) % mod);
  return 0;
}
