
      program main

        implicit none
        integer L, tmpL, digit, c
        integer i, t
        logical k(20)

        read(*,*) L
        tmpL = L

        c = 0
        do i=1,20
          k(i) = .false.
        enddo

        digit = 1
        do
          if ( tmpL .eq. 0 ) goto 100
          if ( iand(tmpL,1) .ne. 0 ) then
            k(digit) = .true.
            c = c + 1
          endif
          tmpL = ishft(tmpL, -1)
          digit = digit + 1
        enddo
100     continue

        write(*, '(I0,X,I0)') digit-1, (digit-2)*2+(c-1)


        t = 1
        do i=1, digit-2
          write(*, '(I0,X,I0,X,I0)') i, i+1, 0
          write(*, '(I0,X,I0,X,I0)') i, i+1, t
          if ( k(i) .eqv. .true. ) then
            write(*, '(I0,X,I0,X,I0)') i, digit-1, L-t
            L = L - t
          endif
          t = ishft(t, 1)
        enddo

      end