#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
ll po(ll a, ll n)
{
ll res = a, ans = 1;
while (n)
{
if (n % 2)
ans = ans * res % mod;
res = res * res % mod;
n /= 2;
}
return ans;
}
int main()
{
ll n;
cin >> n;
cout << po(3, n - 1);
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgbGwgbG9uZyBsb25nCiNkZWZpbmUgbW9kIDEwMDAwMDAwMDcKbGwgcG8obGwgYSwgbGwgbikKewogICAgICAgIGxsIHJlcyA9IGEsIGFucyA9IDE7CiAgICAgICAgd2hpbGUgKG4pCiAgICAgICAgewogICAgICAgICAgICAgICAgaWYgKG4gJSAyKQogICAgICAgICAgICAgICAgICAgICAgICBhbnMgPSBhbnMgKiByZXMgJSBtb2Q7CiAgICAgICAgICAgICAgICByZXMgPSByZXMgKiByZXMgJSBtb2Q7CiAgICAgICAgICAgICAgICBuIC89IDI7CiAgICAgICAgfQogICAgICAgIHJldHVybiBhbnM7Cn0KaW50IG1haW4oKQp7CiAgICAgICAgbGwgbjsKICAgICAgICBjaW4gPj4gbjsKICAgICAgICBjb3V0IDw8IHBvKDMsIG4gLSAxKTsKICAgICAgICByZXR1cm4gMDsKfQ==