def f(a, total) r = [] dp = {} g = lambda{|res, idx| return false if res > total return res == total if idx == a.size return false if dp[[res,idx]] dp[[res,idx]] = true [:+, :*].each{|op| new_res = res.send(op, a[idx]) 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)*""