#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int n;
  cin >> n;
  long long int d = 1e9 + 7;
  long long int r1 = 1, r2 = 1;
  for (int i = 1; i <= n; i++) {
    r1 *= 27;
    r1 = r1 % d;
    r2 *= 7;
    r2 = r2 % d;
  }
  long long int ans = (r1 - r2) % d;
  if (ans < 0)
    cout << d + ans;
  else
    cout << ans;
}
