sub f{join pop,sort split//,pop};$w=f($/.pop,"");die grep $w=~(f($_,"+")."+",<>