#include <bits/stdc++.h>
using namespace std;
const long long mod = (1e9) + 7;
int main() {
  long long n;
  cin >> n;
  vector<long long> a(n), pw(4 * n + 1);
  pw[0] = 1;
  for (int i = 1; i <= 4 * n; i++) {
    pw[i] = (pw[i - 1] * 3) % mod;
  }
  a[0] = 20;
  for (long long i = 1; i < n; i++) {
    a[i] = (pw[i * 3] * 20 + a[i - 1] * 7) % mod;
  }
  cout << a[n - 1] << '\n';
  return 0;
}
