#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long int n, t, iv;
  cin >> n;
  t = 27;
  iv = 7;
  n--;
  while (n--) {
    t = ((t % 1000000007) * 27) % 1000000007;
    iv = ((iv % 1000000007) * 7) % 1000000007;
  }
  if (t > iv)
    cout << t - iv;
  else
    cout << 1000000007 - iv + t;
  return 0;
}
