#include <iostream>
using namespace std;

string parse(const string &A, const string &B, int la, int ra, int lb, int rb){
  if(abs(ra-la) < 5 || abs(rb-lb) < 5) return "";
  int t = 0, ra_ = -1, rb_ = -1;
  for(int i = la; i < ra; ++i){
    if(A[i] == '(') ++t;
    if(A[i] == ')') --t;
    if(!t){
      ra_ = i;
      break;
    }
  }
  t = 0;
  for(int i = lb; i < rb; ++i){
    if(B[i] == '(') ++t;
    if(B[i] == ')') --t;
    if(!t){
      rb_ = i;
      break;
    }
  }

  int va = -1, vb = -1, la_ = ra_+1, lb_ = rb_+1;
  if(A.at(la_) == '['){
    ++la_;
    va = 0;
    while(A.at(la_) >= '0' && A.at(la_) <= '9'){
      va *= 10;
      va += A.at(la_) - '0';
      ++la_;
    }
    ++la_;
  }
  if(B.at(lb_) == '['){
    ++lb_;
    vb = 0;
    while(B.at(lb_) >= '0' && B.at(lb_) <= '9'){
      vb *= 10;
      vb += B.at(lb_) - '0';
      ++lb_;
    }
    ++lb_;
  }
  string ret = "(" + parse(A,B,la+1,ra_-1,lb+1,rb_-1) + ")";
  if(va >= 0 && vb >= 0) ret += "[" + to_string(va+vb) + "]";
  ret += "(" + parse(A,B,la_+1,ra-1,lb_+1,rb-1) + ")";
  return ret;
}

int main(){
  string A, B;
  cin >> A >> B;
  cout << parse(A,B,0,A.length(),0,B.length()) << endl;
  return 0;
}

