program sample
    implicit none
    character(1)::s(3)
    integer(8) :: i,j,m,n,p,x,t(4)
    integer(8),allocatable :: y(:)
  
    read(*,*) n
    t(1)=n/1000
    n=n-t(1)*1000
    t(2)=n/100
    n=n-t(2)*100
    t(3)=n/10
    t(4)=n-t(3)*10
    s(:)='+'
    
    do i=0,8
        x=t(1)
        m=i
        if (mod(m,2)==0)then
            s(3)='-'
            x=x-t(4)
        else
            s(3)='+'
            m=i-1
            x=x+t(4)
        end if
        
        if (mod(m,4)==0)then
            s(2)='-'
            x=x-t(3)
        else
            s(2)='+'
            m=m-2
            x=x+t(3)
        end if
        if (mod(m,8)==0)then
            s(1)='-'
            x=x-t(2)
        else
            s(1)='+'
            x=x+t(2)
        end if
        if (x==7)then
            write(*,'(i1.1,a,i1.1,a,i1.1,a,i1.1,a)')t(1),s(1),t(2),s(2),t(3),s(3),t(4),'=7'
            stop
        end if
    end do

    stop
end program sample
  

