const length = parseInt( readline() ) const arr = [] for( let i = 0; i < length; i ++ ) { const itemArr = readline().split(" ") arr.push(itemArr) } const str = readline() const numberArr = [] const todoArr = [] let sum = 0; function mul( arr1, arr2 ) { const [ x, xy ] = arr1 const [ yy, z ] = arr2 const currentSum = x * xy * z sum += currentSum return [ x, z ] } function calc() { const right = numberArr.pop() const left = numberArr.pop() const current = mul( left, right ) numberArr.push(current) todoArr.pop() } for( let i = 0, l = str.length; i < l; i++ ) { if( str[i] === "(" ) { todoArr.push("(") }else if( str[i] === ")" ) { calc() }else { numberArr.push( arr.shift() ) } } while( todoArr.length ) { calc() } console.log( sum )