lambda sys lambda FI lambda lambda lambda lambda lambda sys stdout wri

1
(lambda sys:(lambda FI:(lambda(N,T):(lambda I,y,Y,U:(lambda G:(lambda C:(lambda _:([sys.stdout.write('%s\n' % x)for x in[' + '.join(' * '.join(map(str,i))for i in map(lambda x:x[0],s[1:]))for s in(lambda S:(_(_,[0],S)and False)or S)([])]]))((lambda _,Q,S:(lambda e:((C(Q,S)and S.append(G(Q)))or True)if(e==N)else(False if(e>N)else(((lambda g:([(I.__setitem__(n,I.get(n,0)+1))or(not(g['b']))and(((Q[-1]not in(0,1))and(n!=1))and((Q.append('*')or Q.append(n))or(not(_(_,Q,S))and(g.__setitem__('b',True)))or(Q.pop()and False)or(Q.pop()and False)))or((Q.append('+')or Q.append(n))or(not(_(_,Q,S))and(g.__setitem__('b',g.get('b')and True)))or(Q.pop()and False)or(Q.pop()and False))or(I.__setitem__(n,I.get(n,0)-1)) for(n,c)in filter(lambda(n,c):I[n]<c,T)]and False))({'b':False}))or True)))(E(Q,U)))))(lambda Q,S:G(Q)not in S))(lambda q:(lambda q,Z:Y((Z(Y(y(Y(i),'*'))))for i in y(q,'+')))(q,Z)))(dict((n,0)for(n,c)in T),lambda q,t:(lambda g:(([(g['o'].append(tuple(g['a']))or(g.__setitem__('a',[])))if(i==t)else(g['a'].append(i))for i in(tuple(q)+(t,))])and False)or(tuple(g['o'])))({'o':[],'a':[]}),lambda x:(lambda X:X.sort()or tuple(X))(list(x)),(lambda J:{'*':J.mul,'+':J.add})(__import__('operator'))))((lambda N:(N,filter((lambda(n,c):(n<=N)and(n>0)),(lambda f:(f.sort(key=lambda(n,c):n)or f))(map(lambda x:map(int,x.split()),FI.readlines())))))(int(FI.readline().strip()))))(sys.stdin))(eval(compile('def Z(q):\n\twhile(len(q)>0)and(q[0]==()):q=q[1:]\n\treturn q\n\ndef E(Q,U):\n\ts,o=[],[]\n\tfor c in Q:\n\t\tif type©in(int,long):\n\t\t\to.append©\n\t\telif type©is str:\n\t\t\twhile (len(s)>0)and(type(s[-1])is str)and(((c==\'+\')and(s[-1]==\'*\'))or(c==s[-1])):o.append(U[s.pop()](o.pop(),o.pop()))\n\t\t\ts.append©\n\twhile s:o.append(U[s.pop()](o.pop(),o.pop()))\n\treturn o[0]\n','','exec'),globals(),locals())or __import__('sys'))