#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
long long ksm(long long a, long long n) {
  long long re = 1;
  while (n) {
    if (n & 1) re = (re * a) % MOD;
    n >>= 1;
    a = (a * a) % MOD;
  }
  return re % MOD;
}
int main() {
  long long n;
  cin >> n;
  long long ans = ksm(27, n) - ksm(7, n);
  if (ans < 0) ans += MOD;
  cout << ans << endl;
  return 0;
}
