#include <bits/stdc++.h>
long long n, ans, num, sum;
const long long mod = 1000000007ll;
long long pow(long long a, long long b) {
  long long r = 1ll;
  while (b) {
    if (b & 1) r = r * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return r % mod;
}
int main() {
  scanf("%I64d", &n);
  num = pow(27ll, n);
  sum = pow(7ll, n);
  if (num < sum) num = num + mod;
  printf("%I64d\n", (num - sum) % mod);
  return 0;
}
