#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int c = 1000000007, k = 1, k1 = 1, i, n;
  cin >> n;
  for (i = 1; i <= n; i++) {
    k = k * 27;
    k1 = k1 * 7;
    k = k % c;
    k1 = k1 % c;
  }
  if (k < k1)
    cout << k - k1 + c;
  else
    cout << k - k1;
  return 0;
}
