N = int(input()) if N == 0: print(1) if N == 1: print(12) if N == 2: print(61) if N >= 3: print(((3*N+3)*(3*N+3)-12)//2%(10**9+7))