      program avg

      character cline * 80

      istart = 0

      do  m = 1, 6

      do  n = 1, 6
        read(*,'(a80)') cline
      enddo

      if ( istart .eq. 0 ) then 
        read(*,*) num
        istart = 1
      endif

      rmsum = 0.0
      nm    = 0

      do  n = 1, num
        read(*,*) x, rm
        if ( x .ge. 1.2 ) then
          rmsum = rmsum + rm
          nm    = nm + 1
        endif
      enddo

      rmavg = rmsum / nm
      write(*,*) 'm, avg = ', m, rmavg

      enddo

      stop
      end
