#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
long long n;
long long binpow(long long a, long long x) {
  if (x == 1) return a;
  if (x % 2 == 0) {
    long long b = binpow(a, x / 2) % MOD;
    return (b * b) % MOD;
  } else {
    return (a * binpow(a, x - 1) % MOD) % MOD;
  }
}
signed main() {
  cin >> n;
  long long all = binpow(27, n), bad = binpow(7, n);
  if (all - bad < 0) {
    cout << MOD + all - bad << "\n";
  } else {
    cout << all - bad << "\n";
  }
  return 0;
}
