def input
  line = STDIN.gets and line.split.map &:to_i
end

Problem = Struct.new(:target, :num) do
  def self.read
    t, num = input
    return nil if !t || t == 0
    new t, num
  end
  
  def solve
    chars = num.to_s
    max = -1
    lesser = -1
    max_digits = nil
    
    (1 << (chars.size - 1)).times do |n|
      digits = splits_at(chars, n)
      sum = digits.inject(:+)
      if sum <= target && max <= sum
        max, lesser = sum, max
        max_digits = digits
      end
    end
    
    if max < 0
      puts :error
    elsif max == lesser
      puts :rejected
    else
      puts [max, *max_digits].join(' ')
    end
  end
  
  def splits_at(str, n)
    i = 0
    chunks = []
    (str.size - 1).times do |j|
      n, m = n.divmod(2)
      next if m == 0
      chunks << str[i..j].to_i
      i = j + 1
    end
    chunks << str[i..-1].to_i
  end
end

while problem = Problem.read
  problem.solve
end