#include using namespace std; template istream& operator>>(istream& is, pair& a){ return is >> a.first >> a.second; } template ostream& operator<<(ostream& os, pair& a){ return os << a.first << " "< istream& operator>>(istream& is, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) is >> vc[i]; return is; } template ostream& operator<<(ostream& os, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) os << vc[i] << endl; return os; } #define ForEach(it,c) for(__typeof (c).begin() it = (c).begin(); it != (c).end(); it++) #define ALL(v) (v).begin(), (v).end() #define UNQ(s) { sort(ALL(s)); (s).erase( unique( ALL(s)), (s).end());} #define fr first #define sc second typedef pair< int , int > Pi; typedef pair< int , Pi > Pii; typedef long long int64; const int INF = 1 << 30; int N, Total, A[50]; bool dp[50][100001]; bool rec(int idx, int sum, long long bit){ if(sum > Total){ return(false); } if(idx == N){ if(sum == Total){ for(int i = 1; i < N; i++){ putchar(((bit >> (long long)i) & 1) ? '+' : '*'); } putchar('\n'); return(true); } else { return(false); } } if(dp[idx][sum]) return(false); if(rec( idx + 1, sum + A[idx], bit|(1LL << idx))) return(true); if(rec( idx + 1, sum * A[idx], bit)) return(true); dp[idx][sum] = true; return(false); } int main(){ cin >> N; cin >> Total; for(int i = 0; i < N; i++){ cin >> A[i]; } rec(0, 0, 0); }