      program A2A1
      implicit none
      integer nmax,nm
      parameter (nmax=1000)

      integer k
      real z(nmax),q(nmax)
      real z1,z2,qz1,qz2,A2,A1

      open (10,file='tmp0',form='formatted')

      read(*,*) z1
      read(*,*) z2

      do k=1,nmax
         read(10,*,end=999) q(k),z(k)
         z(k)=z(k)*1000.
         nm=k
      enddo

 999   continue

      if (z(nm).lt.z2) then
         print*,'ATTENTION !!! ',z2,z(nm)
         stop
      endif


      A2=q(1)*z(1)
      A1=0.
      do k=1,nm-1
         if (z(k).lt.z1) then
            if (z(k+1).ge.z1) then
               qz1=q(k)+(z1-z(k))*
     s             (q(k+1)-q(k))/(z(k+1)-z(k))
               A2=A2+(z1-z(k))*0.5*(qz1+q(k))
               A1=A1+(z(k+1)-z1)*0.5*(qz1+q(k+1))
            else
               A2=A2+(z(k+1)-z(k))*0.5*(q(k)+q(k+1))
            endif
         else if (z(k).lt.z2) then
            if (z(k+1).ge.z2) then
               qz2=q(k)+(z2-z(k))*
     s             (q(k+1)-q(k))/(z(k+1)-z(k))
               A1=A1+(z2-z(k))*0.5*(qz2+q(k))
            else
               A1=A1+(z(k+1)-z(k))*0.5*(q(k)+q(k+1))
            endif
         endif
      enddo
      print*,-A1,A2
      end

