def pow_mod(a, k, p):
t = []
pow_val = 1
a_pow = a % p
while pow_val <= k:
t.append(a_pow)
a_pow = (a_pow*a_pow) % p
pow_val <<= 1
ans = 1
for i in range(len(t)):
if k & 1:
ans = (ans * t[i]) % p
k >>= 1
return ans
def rev_meta(b, p):
return pow_mod(b, p-2, p)
N = int(input())
meta = rev_meta(6, 10007 )
val = N % 10007
val1 = (val + 1) % 10007
val2 = (val + 2) % 10007
ans = 1
for v in [meta, val, val1, val2]:
ans *= v
ans %= 10007
print(ans)