//38
#include<iostream>

using namespace std;

char *a,*b;

void si(char **s,bool f){
  if(**s!='(')return;
  if(f){
    cout<<**s;
  }
  ++*s;
  if(**s=='('){
    si(s,f);
  }
  if(f){
    cout<<**s;
  }
  ++*s;
  if(**s=='('){
    si(s,f);
  }
  if(f){
    cout<<**s;
  }
  ++*s;
}

void op(int f){
  if(*a!='(')return;
  cout<<*a;
  a++;
  b++;
  if(!(*a==*b&&*a==',')){
    if(*a==*b){
      op(f);
    }else{
      si(&a,f);
      si(&b,f);
    }
  }
  cout<<*a;
  a++;
  b++;
  if(!(*a==*b&&*a==')')){
    if(*a==*b){
      op(f);
    }else{
      si(&a,f);
      si(&b,f);
    }
  }
  cout<<*a;
  a++;
  b++;
}
 
int main(){
  for(char o;cin>>o;){
    char sa[301],sb[301];
    a=sa;
    b=sb;
    cin>>sa>>sb;
    op(o=='u');
    cout<<endl;
  }
  return 0;
}