def f(a, total) r = [] g = lambda{|res, idx| return false if res > total return res == total if idx == a.size [:+, :*].each{|op| new_res = res.send(op, a[idx]) next if new_res > total r << op if g.(new_res, idx+1) return true end r.pop } false } first = a.shift g.(first, 0) r end N = gets.to_i Total = gets.to_i A = gets.split.take(N).map(&:to_i) puts f(A, Total)*""