#include <iostream>
#include <string>
using namespace std;


struct Xcsr {
    int depth;
    string::iterator c;
};

int main() {
    char op;
    string ex1, ex2;
    int i;

    while (cin >> op >> ex1 >> ex2) {

        Xcsr x[2], *xa, *xb;
        x[0].depth = x[1].depth = 0;
        x[0].c = ex1.begin();
        x[1].c = ex2.begin();
        string result;
        while (x[0].c != ex1.end() || x[1].c != ex2.end()) {

            for (i = 0; i < 2; i++) {
                if (*(x[i].c) == '(') {
                    x[i].depth++;
                }
                else if (*(x[i].c) == ')') {
                    x[i].depth--;
                }
            }
            if (*(x[0].c) == *(x[1].c) && x[0].depth == x[1].depth) {
                result += *(x[0].c);
            }
            else {
                if (x[0].depth > x[1].depth) {
                    xa = &x[0];
                    xb = &x[1];
                }
                else {
                    xa = &x[1];
                    xb = &x[0];
                }
                while (*(xa->c) != *(xb->c) || xa->depth != xb->depth) {
                    if (op == 'u') result += *(xa->c);
                    xa->c++;
                    if (*(xa->c) == '(') {
                        xa->depth++;
                    }
                    else if (*(xa->c) == ')') {
                        xa->depth--;
                    }
                }
                result += *(x[0].c);
            }
            x[0].c++;
            x[1].c++;
        }
        cout << result << endl;
    }
    return 0;
}