#include <bits/stdc++.h>
using namespace std;
const int MAX = 100010;
const int mod = 1000000000 + 7;
int N;
long long cir[MAX];
long long Time[MAX];
int main() {
  scanf("%d", &N);
  memset(cir, 0, sizeof(cir));
  memset(Time, 0, sizeof(Time));
  cir[1] = 20;
  Time[0] = 1;
  Time[1] = 7;
  for (int i = 2; i <= N; i++) {
    cir[i] = (27 * cir[i - 1] % mod + 20 * Time[i - 1] % mod) % mod;
    Time[i] = Time[i - 1] * 7 % mod;
  }
  printf("%I64d\n", cir[N]);
  return 0;
}
