#include <bits/stdc++.h>
using namespace std;
const long long N = 151000;
const long long maxm = 105;
const long long mod = 1e9 + 7;
long long n, t, m;
signed main() {
  cin >> n;
  m = n;
  long long sum = 1, s = 1;
  while (m--) {
    sum = (sum * 27) % mod;
  }
  while (n--) {
    s = (s * 7) % mod;
  }
  if (sum < s)
    printf("%lld\n", sum + mod - s);
  else
    printf("%lld\n", sum - s);
  return 0;
}
