	parameter (n=20000)
	parameter (m=200)
	real a(n),b(n),mag(n),sky(n)
	character*60 f1,f2,f3
	character*79 tit
	open(1,file='mknad.ap',status='old')
	open(2,file='psfcand.coo',status='old')
	open(3,file='mknad.lst',status='unknown')

	do 10 i=1,3
	read(1,'(a)')tit
	write(*,*)tit
10	write(3,*)tit
	do 20 i=1,n
	read(1,*,end=100)j,a(i),b(i),mag(i)
20	read(1,*,end=100)sky(i)
100	nn=i-1
	close(1)

	do 30 i=1,m
	read(2,*,end=200)c,d
	y=10000.
	k=0
	do 40 j=1,nn
	x=abs(a(j)-c)+abs(b(j)-d)
	if(x.lt.y)then
	  y=x
	  k=j
	  c1=a(j)
	  d1=b(j)
	  xmag=mag(j)
	  xsky=sky(j)
	endif
40	continue
	write(*,1)k,c1,d1,c,d
30	write(3,1)k,c1,d1,xmag,xsky
1	format(i6,4f11.3)
200	close(2)
	close(3)
	end
