      parameter (nmax=2000,mmax=61)
      character *10 nome,nomeout
      integer date(nmax),chron(nmax),aval(10)
      do j=1,9
         id1 = j
         nome = 
     $        char(48+id1)//'.txt'
         nomeout = 'vag0'//
     $        char(48+id1)//'.dat'
         open (unit=3,file=nome,status='old')
         open (unit=4,file=nomeout,status='unknown')
         icount = 0
         read (3,*)
         read (3,*)
         do k=1,nmax
            read (3,*,end=99) iyear0,(aval(i),i=1,10)
            do jj=1,10
               icount = icount+1
               iy =iyear0+jj-1
               chron(icount)=aval(jj)
               date(icount)=iy
            end do
         end do
99       nx = icount
         do k=1,nx
            if (chron(k).gt.0) then
              istart = k
              goto 33
            endif 
         end do
33       do k=nx,1,-1
            if (chron(k).gt.0) then
              iend = k
              goto 44
            endif
         end do
44       do k=istart,iend
            write (4,*) date(k),chron(k)
         end do
         close (unit=3)
         close (unit=4)
      end do
c
      do j=10,54
         id1 = j/10
         id2 = j-10*id1
         nome = 
     $        char(48+id1)//
     $        char(48+id2)//'.txt'
         nomeout = 'vag'//
     $        char(48+id1)//
     $        char(48+id2)//'.dat'
         open (unit=3,file=nome,status='old')
         open (unit=4,file=nomeout,status='unknown')
         icount = 0
         read (3,*)
         read (3,*)
         do k=1,nmax
            read (3,*,end=88) iyear0,(aval(i),i=1,10)
            do jj=1,10
               icount = icount+1
               iy =iyear0+jj-1
               chron(icount)=aval(jj)
               date(icount)=iy
            end do
         end do
88       nx = icount
         do k=1,nx
            if (chron(k).gt.0) then
              istart = k
              goto 333
            endif 
         end do
333       do k=nx,1,-1
            if (chron(k).gt.0) then
              iend = k
              goto 444
            endif
         end do
444       do k=istart,iend
            write (4,*) date(k),chron(k)
         end do
         close (unit=3)
         close (unit=4)
      end do
c
      do j=56,mmax
         id1 = j/10
         id2 = j-10*id1
         nome = 
     $        char(48+id1)//
     $        char(48+id2)//'.txt'
         nomeout = 'vag'//
     $        char(48+id1)//
     $        char(48+id2)//'.dat'
         open (unit=3,file=nome,status='old')
         open (unit=4,file=nomeout,status='unknown')
         icount = 0
         read (3,*)
         read (3,*)
         do k=1,nmax
            read (3,*,end=77) iyear0,(aval(i),i=1,10)
            do jj=1,10
               icount = icount+1
               iy =iyear0+jj-1
               chron(icount)=aval(jj)
               date(icount)=iy
            end do
         end do
77       nx = icount
         do k=1,nx
            if (chron(k).gt.0) then
              istart = k
              goto 3
            endif 
         end do
3       do k=nx,1,-1
            if (chron(k).gt.0) then
              iend = k
              goto 4
            endif
         end do
4       do k=istart,iend
            write (4,*) date(k),chron(k)
         end do
         close (unit=3)
         close (unit=4)
      end do
c
c
      stop
      end
