#include<cstdio>
#include<cstring>
#include<cstdlib>

typedef struct _tree {
    struct _tree *left, *right;
    int node;
} tree;

char *p;
bool analyze(tree *dst) {
    dst->left = dst->right = NULL;
    switch(*p) {
        case ')':
            p++;
            return false;
        case '(':
            dst->left = (tree*)malloc(sizeof(tree));
            p++;
            if(!analyze(dst->left)) dst->left = NULL;
            break;
    }
    p++;
    dst->node = 0;
    while('0' <= *p && *p <= '9')
        dst->node*=10, dst->node+=(*p-'0'), p++;
    p++;
    p++;

    dst->right = (tree*)malloc(sizeof(tree));
    if(!analyze(dst->right)) dst->right = NULL;
    p++;
    return true;
}

void print_tree(tree *tr) {
    printf("(");
    if(tr->left) print_tree(tr->left);
    printf(")");

    printf("[");
    printf("%d", tr->node);
    printf("]");

    printf("(");
    if(tr->right) print_tree(tr->right);
    printf(")");
}

void unite(tree *tr1, tree *tr2) {
    (tr1->left && tr2->left) ? unite(tr1->left, tr2->left),tr1->left : tr1->left = NULL;
    (tr1->right && tr2->right) ? unite(tr1->right, tr2->right),tr1->left : tr1->right = NULL;
    tr1->node += tr2->node;
}

int main(void) {
    char s[2000], t[2000];
    tree st, tt;

    scanf("%s%s",s,t);
    p = s;
    analyze(&st);
    p = t;
    analyze(&tt);

    unite(&st, &tt);

    print_tree(&st);
    puts("");
    return 0;
}