program string_equivalence
  integer :: n
  character(10) :: s = ""
  read(*,*) n
  call dfs(1,0)
contains
  recursive subroutine dfs(i,v)
    integer, intent(in) :: i, v
    integer :: j
    do j = 1, v+1
      s(i:i) = achar(j+96)
      if (i == n) then
        write(*,'(a)') trim(s)
      else
        call dfs(i+1,j)
      end if
    end do
  end
end program string_equivalence