#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vecI = vector<int>;
using vec2I = vector<vecI>;
using vec3I = vector<vec2I>;
ll mod{(ll)1e9 + 7};
double pi = 2 * acos(0.0);
void solve() {
  ll n;
  cin >> n;
  pair<ll, ll> prev{20LL, 20LL};
  for (ll i{1}; i < n; i++) {
    prev.first *= 27;
    prev.first %= mod;
    prev.second = (prev.first + (7 * prev.second) % mod) % mod;
  }
  cout << prev.second;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
