#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF=2e18;
string A,B;
typedef string::const_iterator SC;
ll NumParse(SC& it){
    it++;
    ll ret=0;
    while(isdigit(*it)){
        ret*=10;
        ret+=*it-'0';
        it++;
    }
    return ret;
}
string Func(ll al, ll ar,ll bl,ll br){
    //cout<<"ok"<<endl;
    ll rootA;
    ll rootBeginA;
    ll rootEndA;
    ll lCount=0;
    ll rCount=0;
    for(ll i=al;i<=ar;i++){
        if(A[i]=='('){
            lCount++;
        }else if(A[i]==')'){
            rCount++;
        }else if(A[i]=='['){
            if(lCount==rCount){
                SC sc=A.begin()+i;
                rootBeginA=i;
                rootA = NumParse(sc);
                rootEndA=sc-A.begin();
                break;
            }
        }
    }
    ll rootB;
    ll rootBeginB;
    ll rootEndB;
    lCount=0;
    rCount=0;
    for(ll i=bl;i<=br;i++){
        if(B[i]=='('){
            lCount++;
        }else if(B[i]==')'){
            rCount++;
        }else if(B[i]=='['){
            if(lCount==rCount){
                SC sc=B.begin()+i;
                rootBeginB=i;
                rootB = NumParse(sc);
                rootEndB=sc-B.begin();
                break;
            }
        }
    }
    string ret="";
    if((A[rootBeginA-2]=='(' && A[rootBeginA-1]==')') || (B[rootBeginB-2]=='(' && B[rootBeginB-1]==')')){
        ret+="()";
    }else{
        ret+='(';
        ret+=Func(al+1,rootBeginA-2,bl+1,rootBeginB-2);
        ret+=')';
    }
    ret+="["+to_string(rootA+rootB)+"]";
    if((A[rootEndA+1]=='(' && A[rootEndA+2]==')') || (B[rootEndB+1]=='(' && B[rootEndB+2]==')')){
        ret+="()";
    }else{
        ret+='(';
        ret+=Func(rootEndA+2,ar-1 ,rootEndB+2,br-1);
        ret+=')';
    }
    return ret;
}

int main(){
    cin>>A;
    cin>>B;
    cout<<Func(0,A.length()-1,0,B.length()-1)<<endl;

    return 0;
}
