using System; using System.Collections.Generic; using System.IO; using System.Linq; public class Do { private MyConsole mc = new MyConsole(); public void Solve() { var N = mc.Int(); var Total = mc.Int(); var A = mc.IntSplit(); bool found = false; Func act = null; act = ( Formula, Base, Index ) => { if (found) return true; if (Base < Total && Index < N) { Formula[Index - 1] = false; if (act( Formula, Base + A[Index], Index + 1 )) return true; Formula[Index - 1] = true; if (act( Formula, Base * A[Index], Index + 1 )) return true; } else if (Base == Total && Index == N) { string ans = string.Empty; foreach (var item in Formula) ans += item ? "*" : "+"; mc.wLine( ans ); found = true; } return false; }; // 演算の実行 act( new bool[N - 1], A[0], 1 ); } } public class Program { public static void Main() { MyConsole.Read(); var Do = new Do(); Do.Solve(); MyConsole.Finish(); } } public class MyConsole { private static List ReadedLine = new List(); private char[] buf = new char[1024]; private int i; public static void Read() { string sr = Console.In.ReadToEnd(); ReadedLine = sr.Split( new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries ).ToList(); Console.SetOut( new StreamWriter( Console.OpenStandardOutput() ) { AutoFlush = false } ); } public string String() { return ReadedLine[i++]; } public string[] StringSplit() { return ReadedLine[i++].Split( new[] { ' ' } ); } public int Int() { return int.Parse( ReadedLine[i++] ); } public int[] IntSplit() { string[] strs = StringSplit(); int[] ret = new int[strs.Length]; for (int i = 0 ; i < strs.Length ; i++) { ret[i] = int.Parse( strs[i] ); } return ret; } public long Long() { return long.Parse( ReadedLine[i++] ); } public double Double() { return double.Parse( ReadedLine[i++] ); } public void wLine( string output = null ) { Console.WriteLine( output ); } public static void Finish() { Console.Out.Flush(); } }