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