#include <bits/stdc++.h>
using namespace std;
long long dp[100005][2];
int nowdp;
int main() {
  int n;
  dp[1][1] = 20;
  dp[1][0] = 7;
  nowdp = 1;
  while (cin >> n) {
    if (nowdp >= n)
      cout << dp[n][1] << "\n";
    else {
      for (int i = nowdp + 1; i <= n; i++) {
        dp[i][1] = dp[i - 1][1] * 27 + dp[i - 1][0] * 20;
        dp[i][0] = dp[i - 1][0] * 7;
        dp[i][1] %= 1000000007;
        dp[i][0] %= 1000000007;
      }
      cout << dp[n][1] << "\n";
    }
  }
  return 0;
}
