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

using VI = vector<long>;
struct tree {
  int node;
  tree *left;
  tree *right;
};

int p;
tree *parse(string s) {
  tree *t;
  t = (tree*)malloc(sizeof(tree));
  // left
  assert(s[p] == '(');
  if (s[p+1] == ')') {
    p += 2;
    return NULL;
  } else {
    p++;
    t->left = parse(s);
  }
  // center
  assert(s[p] == '[');
  p++;
  int l = 0;
  while(s[p+l] != ']') {
    l++;
  }
  t->node = stoi(s.substr(p, l));
  p += l+1;
  // right
  assert(s[p] == '(');
  t->right = parse(s);
  p++;
  return t;
}

string t_to_str(tree *t) {
  if (t == NULL) {
    return "";
  }
  return "(" + t_to_str(t->left) + ")[" + to_string(t->node) + "](" + t_to_str(t->right) + ")";
}

tree *get_sum(tree *t1, tree *t2) {
  tree *t;
  if (t1 == NULL || t2 == NULL) {
    return NULL;
  } else {
    t = (tree*)malloc(sizeof(tree));
    t->node = t1->node + t2->node;
    t->left = get_sum(t1->left, t2->left);
    t->right = get_sum(t1->right, t2->right);
    return t;
  }
}

int main() {
  string A, B;
  cin >> A >> B;
  if (A != "()") {
    A = "(" + A + ")";
  }
  if (B != "()") {
    B = "(" + B + ")";
  }

  tree *a, *b;
  p = 0;
  a = parse(A);
  p = 0;
  b = parse(B);
  cout << t_to_str(get_sum(a, b)) << endl;
}

