program classified
  implicit none
  integer :: n, i, j, k
  read(*,*) n
  do i = 1, n-1
    do j = i+1, n
      do k = 1, 9
        if (btest(i,k-1) .eqv. btest(j,k-1)) cycle
        write(*,'(i0)',advance='no') k
        if (j /= n) write(*,'(a)',advance='no') " "
        exit
      end do
    end do
    write(*,*)
  end do
end program classified