#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<long long>;
using vpi = vector<pair<long long, long long>>;
using pi = pair<long long, long long>;
const long long nax = 1e5 + 7;
const long long mod = 1e9 + 7;
const long long inf = numeric_limits<long long>::max() - (long long)9e6;
long long power(long long a, long long b) {
  if (b == 0) return 1LL;
  long long ans = power(a, b / 2) % mod;
  (ans *= ans) %= mod;
  if (b & 1) (ans *= a) %= mod;
  return ans;
}
long long n;
void test() {
  cin >> n;
  long long ans = power(27, n) - power(7, n);
  ans += mod;
  ans %= mod;
  cout << ans;
}
signed main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  long long T = 1;
  while (T--) {
    test();
    cout << "\n";
  }
  return 0;
}
