program main
    implicit none

    integer(8) X, Y, N

    read(*,*) X, Y

    do N = X, 1000000000000000000
        if(mod(N,X)==0.and.mod(N,Y)/=0)
            write(*,*) N
            stop
        endif
    enddo

    write(*,*) -1


end program