#include #define MOD(i) ((i)%1000000007) int main() { long long N; scanf("%lld", &N); long long n = 1; long long m = 5; if (N == 1) n = 2; // single: 1, 8 else if (N & 1) n = 3; // odd center: 0, 1, 8 N >>= 1; if (N > 0) { N--; n *= 4; // both ends: 1, 8, 6, 9 } for ( ; N; N >>= 1) { if (N & 1) n = MOD(n * m); m = MOD(m * m); } printf("%lld\n", n); return 0; }