#include <bits/stdc++.h>
using namespace std;
long long pow(long long a, long long b, long long c) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % c;
    a = (a * a) % c;
    b >>= 1;
  }
  return ans;
}
int main() {
  int cnt = 0;
  for (int i = 1; i <= 3; ++i)
    for (int j = 1; j <= 3; ++j)
      for (int k = 1; k <= 3; ++k)
        if (i + j + k == 6) cnt++;
  int n;
  while (scanf("%d", &n) == 1) {
    cout << (pow(3, 3 * n, 1000000007) - pow(cnt, n, 1000000007) + 1000000007) %
                1000000007
         << '\n';
  }
}
