N=input() M=10**9+7 print(3*(1-N%2*2)+pow(3,N,M))*-~M/4%M