#include <bits/stdc++.h>
using namespace std;
const int m = 1000000007;
long long modpow(int x, int n) {
  long long tmp = x % m;
  long long result = 1;
  while (n > 0) {
    if (n & 1) result = ((result % m) * (tmp % m)) % m;
    tmp = (tmp * tmp) % m;
    n >>= 1;
  }
  return result;
}
int main() {
  int n;
  cin >> n;
  long long l1 = modpow(27, n);
  long long l2 = modpow(7, n);
  if (l1 < 0) l1 += m;
  if (l2 < 0) l2 += m;
  long long ans = l1 - l2;
  if (ans < 0) ans += m;
  ans %= m;
  cout << ans << endl;
}
