#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144 * 4LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()
void init() {

}
typedef struct V {
	int val;
	int left;
	int right;
}V;

int itr[2] = { 1,1 };
V vertexs[2][2001] = {};
int num(State& now) {
	int ans = 0;
	while (*now >= '0' && *now <= '9') {
		ans *= 10;
		ans += *now - '0';
		now++;
	}
	return ans;
}

int make_tree(State& now,int check) {
	if (*now == ')') {
		return 0;
	}
	assert(*now == '(');
	now++;
	int hoge = itr[check];
	itr[check]++;
	vertexs[check][hoge] = V{ 0,make_tree(now,check),0 };
	now++;
	now++;
	vertexs[check][hoge].val = num(now);
	now++;
	now++;
	vertexs[check][hoge].right = make_tree(now, check);
	now++;
	return hoge;
}

string output(int L, int R) {
	string ans;
	if (vertexs[0][L].left != 0 && vertexs[1][R].left != 0) {
		//goto left
		ans += "(" + output(vertexs[0][L].left, vertexs[1][R].left) + ")";
	}
	else {
		ans += "()";
	}
	ans += "[" + to_string(vertexs[0][L].val + vertexs[1][R].val) + "]";
	if (vertexs[0][L].right != 0 && vertexs[1][R].right != 0) {
		//goto right
		ans += "(" + output(vertexs[0][L].right, vertexs[1][R].right) + ")";
	}
	else {
		ans += "()";
	}
	return ans;
}


void solve() {
	int root[2];
	REP(i, 2) {
		string s;
		cin >> s;
		State start = s.begin();
		root[i] = make_tree(start, i);
	}
	cout << output(root[0], root[1]) << endl;
}

int main() {
	init();
	solve();
}
