#include <bits/stdc++.h>
using namespace std;
long long d[100005];
long long p27[100005];
long long f(int n) {
  if (d[n] == -1) {
    d[n] = ((7 * f(n - 1)) + (20 * p27[n - 1])) % 1000000007;
  }
  return d[n];
}
int main() {
  memset(d, -1, sizeof d);
  p27[0] = 1;
  d[1] = 20;
  d[0] = 0;
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    p27[i] = (p27[i - 1] * 27) % 1000000007;
  }
  cout << f(n) << endl;
  return 0;
}
