MOD = 10 ** 9 + 7 N = int(input()) if N <= 2: print([1, 12, 65][N]) else: print((17 * N ** 2 + 6 * N + 1) % MOD)