#include<iostream>
#include<fstream>
#include<string>
#include<cmath>

#define fin cin

using namespace std;

bool isValue(char c){
    return 48 <= (int)c && (int)c <=57;
}


int main(){
    //ifstream fin("in.txt");
    
    string one = "";
    string two = "";

    string ans = "";

    fin >> one;
    fin >> two;

    //cout << one << endl;
    //cout << two << endl;

    auto one_kakko = 0;
    auto two_kakko = 0;
    auto one_sub = 0;
    auto two_sub = 0;
    auto s_size = max(one.size(), two.size());


    while( max(one_sub, two_sub) < s_size)
    {
        //temporary
        auto one_c = one[one_sub];
        auto two_c = two[two_sub];

        if(one_c == '(')one_kakko++;
        else if(one_c == ')')one_kakko--;

        if(two_c == '(')two_kakko++;
        else if(two_c == ')')two_kakko--;

        //???????????§i++?????????
        //cout << one_c << " " << two_c << endl;

        //??±????????????
        if(one_kakko == two_kakko)
        {
            //??°???????????????ans?????????
            if(isValue(one_c) && isValue(two_c))
            {
                int one_num = 0;
                int two_num = 0;

                one_num = (int)one_c - 48;
                two_num = (int)two_c - 48;

                while(isValue(one[one_sub + 1]))
                {
                    one_num *= 10;
                    one_num += (int)one[one_sub + 1] - 48;
                    one_sub++;
                }

                while(isValue(two[two_sub + 1]))
                {
                    two_num *= 10;
                    two_num += (int)two[two_sub + 1] - 48;
                    two_sub++;
                }

                ans += to_string(one_num + two_num);
                //cout << "add " << to_string((int)one_c + (int)two_c - 96) << endl;
            }
            else if(one_c == two_c)//???????????????ans?????????
            {
                ans += one_c;
                //cout << "add " << one_c << endl;
            }
        }
        else//????????±???????????£??????????????¨???????????\????????§++
        {
            int isSame = 1;
            if(one_kakko > two_kakko)
            {
                one_sub++;
                while(isSame < 2)
                {
                    //cout << one[one_sub] << " " << two[two_sub] << endl;
                    if(one[one_sub] == '(')one_kakko++;
                    else if(one[one_sub] == ')')one_kakko--;

                    if(one_kakko == two_kakko)isSame++;
                    one_sub++;
                    //cout << "come one " << isSame << endl;
                }
                one_sub -= 2;
                two_sub--;
            }
            else if(one_kakko < two_kakko)
            {
                two_sub++;
                while(isSame < 2)
                {
                    //cout << one[one_sub] << " " << two[two_sub] << endl;
                    if(two[two_sub] == '(')two_kakko++;
                    else if(two[two_sub] == ')')two_kakko--;

                    if(one_kakko == two_kakko)isSame++;
                    two_sub++;
                    //cout << "come two " << isSame << endl;
                }
                one_sub--;
                two_sub -= 2;
            }
            
        }

        one_sub++;
        two_sub++;
    }


    cout << ans << endl;

    return 0;
}



//((()[8]())[2]())[5](((()[2]())[6](()[3]()))[1](       ))
//((       )[4]())[3](((()[2]())[1](       ))[8](()[3]()))

//(()[1](       ))[2](()[3]())
//(()[1](()[2]()))[3](       )

Measured memory_bytes: 3292