#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100001;
const int MOD = 1000000007;
long long proper_ways[MAXN];
long long all_ways[MAXN];
int N;
int main() {
  all_ways[1] = 27;
  proper_ways[1] = 20;
  scanf("%d", &N);
  for (int n = 2; n <= N; n++) {
    all_ways[n] = (27 * all_ways[n - 1]) % MOD;
    proper_ways[n] = (20 * all_ways[n - 1]) % MOD;
    proper_ways[n] += (7 * proper_ways[n - 1]);
    proper_ways[n] %= MOD;
  }
  printf("%I64d\n", proper_ways[N]);
  return 0;
}
