#include <string>
#include <iostream>
using namespace std;
string s, t;
string solve(int sl, int sr, int tl, int tr) {
	if (sl == sr || tl == tr) return "";
	int d1 = 0, sp = -1;
	for (int i = sl; i < sr; i++) {
		if (s[i] == '(') d1++;
		if (s[i] == ')') d1--;
		if (d1 == 0) {
			sp = i; break;
		}
	}
	int d2 = 0, tp = -1;
	for (int i = tl; i < tr; i++) {
		if (t[i] == '(') d2++;
		if (t[i] == ')') d2--;
		if (d2 == 0) {
			tp = i; break;
		}
	}
	int sv = 0, se = -1; sp++;
	for (se = sp + 1; s[se] >= '0' && s[se] <= '9'; se++) sv = sv * 10 + (s[se] - 48); se++;
	int tv = 0, te = -1; tp++;
	for (te = tp + 1; t[te] >= '0' && t[te] <= '9'; te++) tv = tv * 10 + (t[te] - 48); te++;
	string retl = solve(sl + 1, sp - 1, tl + 1, tp - 1);
	string retr = solve(se + 1, sr - 1, te + 1, tr - 1);
	return "(" + retl + ")[" + to_string(sv + tv) + "](" + retr + ")";
}
int main() {
	cin >> s >> t;
	cout << solve(0, s.size(), 0, t.size()) << endl;
	return 0;
}