#include <cassert>
#include <cctype>
#include <functional>
#include <iostream>
#include <string>

using namespace std;

struct Node {
    int value = 0;
    Node* left = nullptr;
    Node* right = nullptr;
    Node(int v, Node* l, Node* r)
        : value{v}
        , left{l}
        , right{r}
    {
    }
};

int main()
{
    string a;
    cin >> a;
    string b;
    cin >> b;

    auto parse = [](const string& str) {
        int i = 0;
        auto value = [&i, &str]() {
            assert(str[i] == '[');
            ++i;
            auto begin = i;
            while (static_cast<bool>(isdigit(str[i]))) {
                ++i;
            }
            assert(str[i] == ']');
            auto end = i - 1;
            return stoi(str.substr(static_cast<size_t>(begin),
                                   static_cast<size_t>(end - begin + 1)));
        };

        function<Node*()> p = [&p, &i, &str, &value]() {
            if (str[i + 1] == ')') {
                i += 2;
                return static_cast<Node*>(nullptr);
            }
            assert(str[i] == '(');
            ++i;
            auto l = p();
            auto v = value();
            ++i;
            auto r = p();
            ++i;
            return new Node{v, l, r};
        };
        auto ll = p();
        auto vv = value();
        ++i;
        auto rr = p();
        return new Node{vv, ll, rr};
    };

    function<void(Node*)> pp = [&pp](Node* n) {
        if (n) {
            cout << "(";
            pp(n->left);
            cout << ")";
            cout << '[' << n->value << ']';
            cout << "(";
            pp(n->right);
            cout << ")";
        }
    };

    function<Node*(Node*, Node*)> f = [&f](Node* l, Node* r) {
        auto ll = l->left && r->left ? f(l->left, r->left) : nullptr;
        auto rr = l->right && r->right ? f(l->right, r->right) : nullptr;
        return new Node{l->value + r->value, ll, rr};
    };

    auto t1 = parse(a);
    //pp(t1);
    //cout << endl;
    auto t2 = parse(b);
    //pp(t2);
    //cout << endl;
    auto r = f(t1, t2);
    pp(r);
    cout << endl;
}