#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<(o)<<" ";}
#define dumpl(o) if(DBG){cerr<<#o<<" "<<(o)<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }


class Parser {
public:
	using Iter = string::const_iterator;
	Iter it;
	Iter it2;
	Parser(Iter it, Iter it2) :it(it), it2(it2) {}
	void cmp(char expected) { if (*it != expected)cerr << *it << " is not " << expected << endl; assert(*it == expected); }
	/*
	EBNF
	??????="(",[??????],")[",??°,"](",[??????],")"
	*/
	void a() {
		if (*it == '('&&*it2 == '(') {
			cmp('('); it++; it2++; cout << '(';
			a();
			cmp(')'); it++; it2++; cout << ')';
			cmp('['); it++; it2++; cout << '[';
			cout << (integer(it) + integer(it2));
			cmp(']'); it++; it2++; cout << ']';
			cmp('('); it++; it2++; cout << '(';
			a();
			cmp(')'); it++; it2++; cout << ')';
		}
		else {
			if (*it == '(') {
				it++;
				a();
				it++;
				it++;
				integer(it);
				it++;
				it++;
				a();
				it++;
			}
			if (*it2 == '(') {
				it2++;
				a();
				it2++;
				it2++;
				integer(it2);
				it2++;
				it2++;
				a();
				it2++;
			}
		}
	}
	int integer(Iter &it) {
		int ret = 0;
		while (isdigit(*it)) {
			ret *= 10;
			ret += *it - '0';
			it++;
		}
		return ret;
	}
};

signed main() {
	string s1, s2; getline(cin, s1); getline(cin, s2);
	s1 += "$"; s2 += "$";
	Parser P(s1.begin(), s2.begin());
	P.a();
	cout << endl;
	return 0;
}