#include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
const int mod = 1000000000 + 7;
int mul(int a, int b) { return ((long long)a * b) % mod; }
void self_add(int& a, int b) {
  a += b;
  if (a >= mod) {
    a %= mod;
  }
}
int pot(int a, int wyk) {
  int res = 1;
  while (wyk) {
    if (wyk & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    wyk >>= 1;
  }
  return res;
}
int inv(int a) { return pot(a, mod - 2); }
vector<int> fact, inv_fact;
int choose(int n, int k) {
  return mul(fact[n], mul(inv_fact[n - k], inv_fact[k]));
}
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  scanf("%d", &n);
  fact.resize(n + 1);
  inv_fact.resize(n + 1);
  fact[0] = inv_fact[0] = 1;
  for (int i = (1); i <= (n); ++i) {
    fact[i] = mul(fact[i - 1], i);
    inv_fact[i] = inv(fact[i]);
  }
  int res = 0;
  for (int i = (1); i <= (n); ++i) {
    int mn = (i % 2 == 1) ? 1 : -1;
    int toAdd = mul(choose(n, i), mul(pot(20, i), pot(27, n - i))) * mn;
    debug() << " ["
            << "choose(n, i)"
               ": "
            << (choose(n, i))
            << "] "
               " ["
            << "toAdd"
               ": "
            << (toAdd) << "] ";
    res = (res + toAdd) % mod;
    if (res < 0) {
      res += mod;
    }
  }
  printf("%d\n", res);
}
