object Main extends App {

  import scala.io.StdIn._

  val Array(n, m) = readLine.trim.split(' ').map(_.toInt)
  val prices = readLine.trim.split(' ').map(_.toInt)

  println(buyLowest(prices, m, n) match {
    case Some(l) ⇒ l.mkString
    case None ⇒ "NA"
  })

  def buyLowest(prices: Array[Int], money: Int, card: Int, current: Int = 0): Option[List[Int]] = {
    if (card == 0) Some(Nil)
    else if (current == 10) None
    else {
      (0 to math.min(card, money / prices(current))).reverse.flatMap{buy ⇒
        buyLowest(prices, money - buy * prices(current), card - buy, current + 1).map{l ⇒ List.tabulate(buy){_ ⇒ current} ++ l}
      }.headOption
    }
  }

  implicit class Extend[T](value: T){
    def also(func: T ⇒ Unit): T = {func(value); value}
    def let[A](func: T ⇒ A): A = func(value)
  }
}
