#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef pair<int, int>P;

int num(string&s, int&i) {
	int n = 0;
	while (isdigit(s[i]))n = n * 10 + s[i++] - '0';
	return n;
}
P E[2][10000];
int v[2][10000];
int cnt;
int calc(string&s, int&i, int id) {
	int l = -1, r = -1;
	i++; if (s[i] == '(') { l = calc(s, i, id); i++; }
	int a = cnt++;
	i += 2; v[id][a] = num(s, i);
	i += 2; if (s[i] == '(') { r = calc(s, i, id); i++; }
	E[id][a].first = l; E[id][a].second = r;
	return a;
}
string dfs(int a, int b) {
	string s = ")[" + to_string(v[0][a] + v[1][b]) + "](";
	if (E[0][a].first != -1 && E[1][b].first != -1) {
		s = "(" + dfs(E[0][a].first, E[1][b].first) + s;
	}
	else s = "(" + s;
	if (E[0][a].second != -1 && E[1][b].second != -1) {
		s += dfs(E[0][a].second, E[1][b].second) + ")";
	}
	else s += ")";
	return s;
}
int main() {
	string a, b; cin >> a >> b;
	int r1, r2;
	int i = 0; r1 = calc(a, i, 0);
	i = 0; r2 = calc(b, i, 1);
	cout << dfs(r1, r2) << endl;
}