#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

using pii = pair<int, int>;

int number(string s, int &i) {
    int res = 0;
    while (isdigit(s[i])) {
        res = 10 * res + (s[i] - '0');
        ++i;
    }
    return res;
}

void dfs(string s, int &i, int lev, int idx, map<pii, int> &num) {
    if (s[i] == ')') return;
    ++i;
    dfs(s, i, lev + 1, 2 * idx, num);
    ++i;
    ++i;
    num[pii(lev, idx)] = number(s, i);
    ++i;
    ++i;
    dfs(s, i, lev + 1, 2 * idx + 1, num);
    ++i;
}

string dfs2(int lev, int idx, map<pii, int> &num) {
    if (!num.count(pii(lev, idx))) return "";
    return "(" + dfs2(lev + 1, 2 * idx, num) + ")[" + to_string(num[pii(lev, idx)]) + "](" + dfs2(lev + 1, 2 * idx + 1, num) + ")";
}

void _main() {
    string A, B;
    cin >> A >> B;
    map<pii, int> numA, numB, numC;
    int i = 0;
    dfs(A, i, 0, 0, numA);
    i = 0;
    dfs(B, i, 0, 0, numB);
    for (auto p : numA) if (numB.count(p.first)) {
        numC[p.first] = numA[p.first] + numB[p.first];
    }
    cout << dfs2(0, 0, numC) << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}
