#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
const int INF = (1LL<<30);
const ll LLINF = (1LL<<60);
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;
//#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

typedef string::const_iterator State;
class ParseError {};
int tree(State&);
int number(State&);

PII t[2][100010], ans[100010];
int idx;
int heap1[100010], heap2[100010], heap[100010];
int val[2][100010], val2[100010];
int cnt;

int tree(State &begin) {
  if(*begin != '(') return -1;
  begin++;
  int left = tree(begin);
  begin++;
  begin++;
  int res = number(begin);
  begin++;
  begin++;
  int right = tree(begin);
  begin++;
  val[idx][cnt] = res;
  t[idx][cnt++] = {left, right};
  // cout << left << " " << cnt-1 << " " << res << " " << right << endl;
  return cnt-1;
}

int number(State &begin) {
  int res = 0;
  while(isdigit(*begin)) {
    res *= 10;
    res += *begin - '0';
    ++begin;
  }
  return res;
}

string dfs(int num) {
  if(num == -1) return "";
  string ret = "(";
  ret += (dfs(ans[num].first));
  ret += (")[");
  ret += (to_string(val2[num]));
  ret += ("](");
  ret += (dfs(ans[num].second));
  ret += (")");
  return ret;
}

int func(int a, int b) {
  if(a == -1 || b == -1) return -1;
  int left = func(t[0][a].first, t[1][b].first);
  int right = func(t[0][a].second, t[1][b].second);
  val2[cnt] = val[0][a] + val[1][b];
  // cout << left << " val2[" << cnt << "] = " << val2[cnt] << " " << right << endl;
  ans[cnt++] = {left, right};
  return cnt-1;
}

signed main(void)
{
  string s, tt;
  cin >> s >> tt;
  memset(val, -1, sizeof(val));
  memset(heap1, -1, sizeof(heap1));
  memset(heap2, -1, sizeof(heap2));
  memset(heap, -1, sizeof(heap));
  idx = 0, cnt = 0;
  State begin = s.begin();
  int root1 = tree(begin);
  idx = 1, cnt = 0;
  begin = tt.begin();
  int root2 = tree(begin);

  memset(val2, -1, sizeof(val2));
  cnt = 0;
  int tmp = func(root1, root2);

  cout << dfs(tmp) << endl;

  return 0;
}