a=int(input()) print(divmod((3-(a%2)*-1+pow(3,a,10**9+7))*(25*10**8+2),10**9+7)[1])