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

struct Node {
    int label;
    Node* lhs;
    Node* rhs;
};

Node *root_l, *root_r;

Node* parse(string s, int l, int r) {
    if(r - l == 0) return nullptr;
    int sum = 0, i = l;
    for(;; i++) {
        if(s[i] == '(') sum++;
        if(s[i] == ')') sum--;
        if(sum == 0 && s[i] == ')') {
            i++;
            break;
        }
    }

    Node* ret = new Node;
    ret -> lhs = parse(s, l+1, i-1);

    i++; // '['
    int num = 0;
    while(isdigit(s[i])) num = num * 10 + (s[i] - '0'), i++;
    ret -> label = num;
    i++; // ']'

    ret -> rhs = parse(s, i+1, r-1);
    return ret;
}

string merge(Node* nl, Node* nr) {
    int value = nl -> label + nr -> label;
    string l = "", r = "";
    if(nl -> lhs && nr -> lhs) l = merge(nl -> lhs, nr -> lhs);
    if(nl -> rhs && nr -> rhs) r = merge(nl -> rhs, nr -> rhs);
    return "(" + l + ")[" + to_string(value) + "](" + r + ")";
}

int main() {
    string s, t; cin >> s >> t;
    root_l = parse(s, 0, s.length());
    root_r = parse(t, 0, t.length());

    cout << merge(root_l, root_r) << endl;
    return 0;
}
