#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <stack>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }
struct Node
{
    int value;
    Node *left, *right;
};
struct Tree
{
    Node *root = nullptr;
    string str = "";
    Tree(string s) : str(s) {}
    Node *getRoot(string target)
    {
        if(target.size() <= 2) return nullptr;
        if(str != target and target.front() == '(' and target.back() == ')')
        {
            target = target.substr(1);
            target.pop_back();
        }
        stack<char> st;
        int num = 0, p, q;
        for(int i = 0; i < (int)target.size(); i++)
        {
            if(st.empty() and target[i] == '[')
            {
                p = i;
                int idx = i + 1;
                while(isdigit(target[idx]))
                {
                    num *= 10;
                    num += target[idx] - '0';
                    idx++;
                }
                q = idx + 1;
            }
            else if(target[i] == ')')
            {
                char ch;
                do { ch = st.top(); st.pop(); }
                while(ch != '(');
            }
            else st.push(target[i]);
        }
        Node *res = new Node;
        res->value = num;
        res->left = getRoot(target.substr(0, p));
        res->right = getRoot(target.substr(q));
        return res;
    }
    void build() { root = getRoot(str); } ;
};
Node *make(Node *A, Node *B)
{
    if(A == nullptr or B == nullptr) return nullptr;
    Node *res = new Node;
    res->value = A->value + B->value;
    res->left = make(A->left, B->left);
    res->right = make(A->right, B->right);
    return res;
}
string create(Node *C)
{
    if(C == nullptr) return "";
    string res = "[" + to_string(C->value) + "]";
    res = "(" + create(C->left) + ")" + res + "(" + create(C->right) + ")";
    return res;
}
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t; cin >> s >> t;
    Tree A(s), B(t);
    A.build(); B.build();
    Node *C = make(A.root, B.root);
    cout << create(C) << endl;
    return 0;
}

