#include <bits/stdc++.h>
using namespace std;

struct node_t{
    node_t *children[2];
    int value;
};

string::iterator state;
bool consume(char c){
    if(*state != c) return false;
    ++state;
    return true;
}
node_t *node(){
    node_t *ret = new node_t();
    assert(consume('('));
    if(consume(')')) ret->children[0] = nullptr;
    else{
        ret->children[0] = node();
        assert(consume(')'));
    }
    assert(consume('['));
    ret->value = 0;
    while(isdigit(*state)){
        ret->value *= 10;
        ret->value += *state - '0';
        ++state;
    }
    assert(consume(']'));
    assert(consume('('));
    if(consume(')')) ret->children[1] = nullptr;
    else{
        ret->children[1] = node();
        assert(consume(')'));
    }
    return ret;
}

node_t *merge(node_t *lhs, node_t *rhs){
    if(lhs == nullptr || rhs == nullptr) return nullptr;
    node_t *ret = new node_t();
    ret->value = lhs->value + rhs->value;
    ret->children[0] = merge(lhs->children[0], rhs->children[0]);
    ret->children[1] = merge(lhs->children[1], rhs->children[1]);
    return ret;
}

void print(node_t *n){
    printf("(");
    if(n->children[0]) print(n->children[0]);
    printf(")[%d](", n->value);
    if(n->children[1]) print(n->children[1]);
    printf(")");
}

int main(){
    string a, b;
    cin >> a >> b;
    state = a.begin();
    auto na = node();
    assert(state == a.end());
    state = b.begin();
    auto nb = node();
    assert(state == b.end());

    print(merge(na, nb));
    printf("\n");
    return 0;
}
