n = int(input()) mod = 10**9+7 if n == 0: print(1) elif n == 1: print(12) elif n == 2: print(65) else: ans = 17*n**2+6*n+1 ans %= mod print(ans)