#include <bits/stdc++.h>
using namespace std;
long long a[100011];
int main() {
  memset(a, 0, sizeof(a));
  long long MAXN = 1000000007;
  long long n;
  long long t;
  t = 1;
  scanf("%I64d", &n);
  a[1] = 20;
  for (long long i = 2; i <= n; i++) {
    t *= 27;
    a[i] = (a[i - 1] * 27) % MAXN + ((t - a[i - 1]) * 20) % MAXN;
    t %= MAXN;
    a[i] %= MAXN;
  }
  printf("%I64d\n", a[n]);
}
