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