#include<iostream>
#include<string>
#include<vector>

using namespace std;

int s2tree(string &A, vector<int> &na, vector<pair<int,int>> &a, int b, int e){
	
	if(e - b <= 2) return -1;
	
	int inb = 0,ine = 0;
	for(int i = b, depth = 0; i < e; i++){
		if(A[i] == '(') {
			depth++;
		} else if(A[i] == ')'){
			depth--;
		}
		
		if(A[i] == '[' && !depth) {
			inb = i+1;
		}
		
		if(A[i] == ']' && !depth) {
			ine = i;
		}
	}

  int number = 0;

	for(int i = inb; i < ine; i++){
		number = number * 10 + A[i] - '0';
	}

  int ca = a.size();

	na.push_back(number);
	
	a.emplace_back(-1,-1);

  int ra = s2tree(A, na, a, b + 1, inb-2);
  int rb = s2tree(A, na, a, ine + 2, e-1);
  a[ca].first = ra;
  a[ca].second = rb;

	return ca;
}

int synthesis(
              vector<pair<int,int>> &a, vector<pair<int,int>> &b, vector<pair<int,int>> &c, vector<int> &na, vector<int> &nb, vector<int> &nc, int ca = 0, int cb = 0){
	
	nc.push_back(na[ca] + nb[cb]);
	c.push_back({-1,-1});
	
	int cc = c.size()-1;
	
	if(a[ca].first != -1 && b[cb].first != -1) {
    int d = synthesis(a, b, c, na, nb, nc, a[ca].first, b[cb].first);
    c[cc].first = d;
	}
	
	if(a[ca].second != -1 && b[cb].second != -1) {
    int d = synthesis(a, b, c, na, nb, nc, a[ca].second, b[cb].second);
    c[cc].second = d;
	}
	
	return cc;
}

string tree2s(vector<int>& nc, vector<pair<int,int>> &c, int cc = 0){
	string ra, rb, rc;
	
	if(cc == -1) return "";
	
	ra = tree2s(nc, c, c[cc].first);
	rc = tree2s(nc, c, c[cc].second);
	
	return "(" + ra + ")" + "[" + to_string(nc[cc]) + "]" + "(" + rc + ")";
}
signed main(){
	string A, B, C;
	vector<int> na, nb, nc;
	vector<pair<int,int>> a, b, c;
	
	cin>>A>>B;
	
	s2tree(A, na, a, 0, A.size());
	s2tree(B, nb, b, 0, B.size());
	synthesis(a, b, c, na, nb, nc);
	
	C = tree2s(nc, c);
	
	cout<<C<<endl;
}

