      real*8, dimension(4,4) :: amat
      real*8, dimension(:,:), allocatable :: pts,pts2
      real*8 :: xscale
c
      open(unit=7,file="amat.051408",status="old")
c
      read(*,*) npts, xscale
      allocate(pts(4,npts), pts2(4,npts))
      do i=1,npts
        read(*,*) pts(1:3,i)
        pts(1:3,i)=pts(1:3,i)*xscale
        pts(4,i)=1.d0
      enddo
c
 10   read(7,*,end=99)
      read(7,*) ((amat(i,j),j=1,4),i=1,4)
      pts2=matmul(amat,pts)/xscale
      write(*,"(1p3e15.7)") ((pts2(k,i),k=1,3),i=1,npts)
      goto 10
c
 99   stop
      end
