#include <bits/stdc++.h>
using namespace std;
int mypow(long long x, long long n, long long m) {
  if (n == 0) return 1 % m;
  long long u = mypow(x, n / 2, m);
  u = (u * u) % m;
  if (n % 2 == 1) u = (u * x) % m;
  return u;
}
int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  long long result;
  long long modulo = 1000000007;
  result = (mypow(27, n, modulo) - mypow(7, n, modulo)) % modulo;
  result = (result % modulo + modulo) % modulo;
  printf("%lld\n", result);
  return 0;
}
