#include <iostream>
#include <vector>
using namespace std;

struct node{
    node *left;
    node *right;
    int cost;
    node() : left(nullptr),right(nullptr),cost(-1){};
};

void treebuild(string &s,node* r,int x,int y){
    if(y<=x+1)return ;
    int cnt =0;
    int tmp=0;
    for(int i=x;i<=y;i++){
        if(s[i]=='('){
            cnt++;
        }else if(s[i]==')'){
            cnt--;
        }
        if(cnt==0){
            tmp = i;
            break;
        }
    }
    int num = 0;
    int tmp2;
    for(int i = tmp+2;i<=y;i++){
        if(s[i]>='0'&&s[i]<='9'){
            num *= 10;
            num += s[i]-'0';
        }else{
            tmp2 = i+1;
            break;
        }
    }
    r->cost = num;
    if(x+1<=tmp-1){
        node* ss = new node();
        r->left = ss;
        treebuild(s,ss,x+1,tmp-1);
    
    }
    if(tmp2+1<=y-1){
        node* tt = new node();
        r->right = tt;
        treebuild(s,tt,tmp2+1,y-1);
    }
    return ;
}

void treecreate(node* ra,node* rb,node* rc){
    rc->cost = ra->cost+rb->cost;
    if(ra->left!=nullptr&&rb->left!=nullptr){
        node *ss = new node();
        rc->left= ss;
        treecreate(ra->left,rb->left,rc->left);
    }
    if(ra->right!=nullptr&&rb->right!=nullptr){
        node *tt = new node();
        rc->right= tt;
        treecreate(ra->right,rb->right,rc->right);
    }
}

string answer(node* r){
    string ans;
    if(r->left!=nullptr){
        ans = "("+answer(r->left)+")";
    }else{
        ans ="()";
    }
    ans +="["+to_string(r->cost)+"]";
    if(r->right!=nullptr){
        ans += "("+answer(r->right)+")";
    }else{
        ans +="()";
    }
    return ans;
}
int main(){
    string A,B;
    cin >> A >> B;
    node* ra = new node();
    node* rb = new node();
    node* rc = new node();
    int n = A.size()-1;
    int m = B.size()-1;
    treebuild(A,ra,0,n);
    treebuild(B,rb,0,m);
    treecreate(ra,rb,rc);
    cout << answer(rc) << endl;
    return 0;
}
