#include <bits/stdc++.h>
using namespace std;
long long pow2(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % 1000000007;
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return res;
}
int main() {
  long long n;
  cin >> n;
  cout << (1000000007 + pow2(27, n) - pow2(7, n)) % 1000000007 << endl;
}
