#include <bits/stdc++.h>
using namespace std;
long long quick(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % 1000000007;
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return ans % 1000000007;
}
int main() {
  long long n;
  while (cin >> n) {
    long long ans = 0;
    if (n == 1)
      ans = 20;
    else {
      for (long long i = 0; i < n; i++) {
        long long t1 = quick(7, i);
        long long t2 = quick(27, n - i - 1);
        long long t = (t1 * 20) % 1000000007;
        if (i < n - 1) t = (t * t2) % 1000000007;
        ans = (ans + t) % 1000000007;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
