#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

ll indexa = 0;
vll numa(1000, -1);
vll para(1000, -1);
vll lefta(1000, -1);
vll righta(1000, -1);

ll indexb = 0;
vll numb(1000, -1);
vll parb(1000, -1);
vll leftb(1000, -1);
vll rightb(1000, -1);

ll makeTree(string s, ll &index, vll &num, vll &par, vll &left, vll &right, ll dep) {
    if (dep > 0) {
        s = s.substr(1, s.size() - 2);
    }
    // cout << "s " << s << endl;
    if (s == "") {
        return -1;
    }
    ll p = 1;
    ll tmp = 1;
    while (p > 0) {
        if(s[tmp] == '(') {
            p++;
        } else if (s[tmp] == ')') {
            p--;
        }
        tmp++;
    }
    string leftstr = s.substr(0, tmp);
    // cout << "left " << leftstr << endl;
    ll leftnum = makeTree(leftstr, index, num, par, left, right, dep + 1);
    tmp++;
    ll lefti = tmp;
    while (s[tmp] - '0' >= 0 && s[tmp] - '0' <= 9) {
        tmp++;
    }
    ll parnum = stoll(s.substr(lefti, tmp - lefti));
    num[index] = parnum;
    ll parindex = index;
    index++;
    string rightstr = s.substr(tmp + 1, s.size() - (tmp + 1));
    // cout << "right " << rightstr << endl;
    ll rightnum = makeTree(rightstr, index, num, par, left, right, dep + 1);
    if (leftnum != -1) {
        par[leftnum] = parindex;
    }
    if (rightnum != -1) {
        par[rightnum] = parindex;
    }
    left[parindex] = leftnum;
    right[parindex] = rightnum;
    return parindex;
}

string solve(ll dep, ll ai, ll bi) {
    if (ai == -1 || bi == -1) {
        return "()";
    }
    ll num = numa[ai] + numb[bi];
    string numstr = "[" + to_string(num) + "]";
    string leftstr = solve(dep + 1, lefta[ai], leftb[bi]);
    string rightstr = solve(dep + 1, righta[ai], rightb[bi]);
    string ans = leftstr + numstr + rightstr;
    if (dep > 0) {
        ans = "(" + ans + ")";
    }
    return ans;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string A, B;
    cin >> A >> B;
    makeTree(A, indexa, numa, para, lefta, righta, 0);
    makeTree(B, indexb, numb, parb, leftb, rightb, 0);
    // REP(i, 0, indexa) {
    //     cout << numa[i] << " " << para[i] << " " << lefta[i] << " " << righta[i] << endl;
    // }
    // REP(i, 0, indexb) {
    //     cout << numb[i] << " " << parb[i] << " " << leftb[i] << " " << rightb[i] << endl;
    // }
    ll art, brt;
    REP(i, 0, indexa) {
        if (para[i] == -1) {
            art = i;
            break;
        }
    }
    REP(i, 0, indexb) {
        if (parb[i] == -1) {
            brt = i;
            break;
        }
    }
    string ans = solve(0, art, brt);
    cout << ans << endl;
}



Measured memory_bytes: 3540