        implicit real*8 (a-h,o-z)
        dimension num(100000),kamo(100000),tani(100000),syuu(100000),
     &  num1(1000),kam1(1000)
        m=1
        i=1
        kamsuu=1
        read(*,*) num(i),kamo(i),tani(i),syuu(i)
        do
        i=i+1
        read(*,*) num(i),kamo(i),tani(i),syuu(i)
        if(num(i).eq.num(i-1)) then
            kamsuu=kamsuu+1
        else
            num1(m)=num(i-1)
            kam1(m)=kamsuu
            kamsuu=1
            if(num(i).eq.9999999) exit
            m=m+1
        end if
        end do
c
        print*,m
        k1=1
        do i=1,m
        print*,num1(i)
        print*,kam1(i)
        k2=k1+kam1(i)
        do j=k1,k2-1
        print*, kamo(j),tani(j),syuu(j)
        end do
        k1=k2
        end do
        end
