#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll binpow(ll a, ll b, ll m) {
  ll res = 1;
  while (b > 0) {
    if (b % 2) res = res * a % m;
    a = a * a % m;
    b /= 2;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  ll mod = 1e9 + 7;
  ll ans = (binpow(27, n, mod) - binpow(7, n, mod));
  if (ans < 0) ans += mod;
  cout << ans;
  return 0;
}
