program infinite_sequence
  implicit none
  integer(8), parameter :: md = 1000000007_8
  integer(8) :: n
  read(*,*) n
  write(*,'(i0)') mod(mod(n*n-1_8,md)*pow(2_8,int(n,4)-2)+1_8,md)
contains
  integer(8) function pow(a,b)
    integer(8), intent(in) :: a
    integer, intent(in) :: b
    integer(8) :: s
    integer :: c
    pow = 0_8
    if (b < 0) return
    pow = 1_8
    s = a
    c = b
    do while (c > 0)
      if (btest(c,0)) pow = mod(s*pow,md)
      s = mod(s*s,md)
      c = rshift(c,1)
    end do
  end
end program infinite_sequence