#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7, N = 1e5 + 10;
long long a[N], b[N];
int main() {
  int n;
  cin >> n;
  a[0] = 1, b[0] = 1;
  for (int i = 1; i <= n; i++) {
    a[i] = a[i - 1] * 27;
    a[i] %= MOD;
    b[i] = b[i - 1] * 7;
    b[i] %= MOD;
  }
  long long res = 0ll;
  for (int i = n - 1; i >= 0; i--) {
    res += a[i] * b[n - 1 - i];
    res %= MOD;
  }
  res *= 27 - 7;
  res %= MOD;
  cout << res << '\n';
  return 0;
}
