Problem: You are given two bracket sequences (not necessarily regular) s and t consisting only of characters '(' and ')'. You want to construct the shortest regular bracket sequence that contains both given bracket sequences as subsequences (not necessarily contiguous).

Recall what is the regular bracket sequence:

  * () is the regular bracket sequence; 
  * if S is the regular bracket sequence, then (S) is a regular bracket sequence; 
  * if S and T regular bracket sequences, then ST (concatenation of S and T) is a regular bracket sequence. 



Recall that the subsequence of the string s is such string t that can be obtained from s by removing some (possibly, zero) amount of characters. For example, "coder", "force", "cf" and "cores" are subsequences of "codeforces", but "fed" and "z" are not.

Input

The first line of the input contains one bracket sequence s consisting of no more than 200 characters '(' and ')'.

The second line of the input contains one bracket sequence t consisting of no more than 200 characters '(' and ')'.

Output

Print one line — the shortest regular bracket sequence that contains both given bracket sequences as subsequences (not necessarily contiguous). If there are several answers, you can print any.

Examples

Input


(())(()
()))()


Output


(())()()


Input


)
((


Output


(())


Input


)
)))


Output


((()))


Input


())
(()(()(()(


Output


(()()()(()()))

Solution (in JAVA):

Solution:
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.util.*;
import java.io.*;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////                                                                                                               /////////
////////                                                                                                               /////////
////////   HHHH        HHHH  EEEEEEEEEEEEE   MMMM          MMMM         OOOOOO             SSSSSSS      EEEEEEEEEEEEE  /////////
////////   HHHH        HHHH  EEEEEEEEEEEEE   MMMMMM      MMMMMM      OOO      OOO        SSSS   SSS     EEEEEEEEEEEEE  /////////
////////   HHHH        HHHH  EEEEE           MMMM MMM  MMM MMMM    OOO          OOO    SSSS       SSS   EEEEE          /////////
////////   HHHH        HHHH  EEEEE           MMMM  MMMMMM  MMMM   OOO            OOO   SSSS             EEEEE          /////////
////////   HHHH        HHHH  EEEEE           MMMM          MMMM  OOO              OOO   SSSSSSS         EEEEE          /////////
////////   HHHHHHHHHHHHHHHH  EEEEEEEEEEE     MMMM          MMMM  OOO              OOO      SSSSSS       EEEEEEEEEEE    /////////
////////   HHHHHHHHHHHHHHHH  EEEEEEEEEEE     MMMM          MMMM  OOO              OOO         SSSSSSS   EEEEEEEEEEE    /////////
////////   HHHH        HHHH  EEEEE           MMMM          MMMM   OOO            OOO              SSSS  EEEEE          /////////
////////   HHHH        HHHH  EEEEE           MMMM          MMMM    OOO          OOO     SSS       SSSS  EEEEE          /////////
////////   HHHH        HHHH  EEEEEEEEEEEEE   MMMM          MMMM      OOO      OOO        SSS    SSSS    EEEEEEEEEEEEE  /////////
////////   HHHH        HHHH  EEEEEEEEEEEEE   MMMM          MMMM         OOOOOO             SSSSSSS      EEEEEEEEEEEEE  /////////
////////                                                                                                               /////////
////////                                                                                                               /////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

public class Contest1 {
    static char[]s,t;
    static int[][][]memo;
    static int dp(int i,int j,int diff){
        if (diff>=500)return 1000000000;
        if (i==s.length&&j==t.length)
            return diff;
        if (memo[i][j][diff]!=-1)return memo[i][j][diff];
        int ans=1+dp(i,j,diff+1);
        if (i<s.length&&s[i]=='('){
            if (j<t.length&&t[j]=='('){
                ans=Math.min(ans,1+dp(i+1,j+1,diff+1));
            }
            else {
                ans=Math.min(ans,1+dp(i+1,j,diff+1));
            }
        }
        if (j<t.length&&t[j]=='('){
            ans=Math.min(ans,1+dp(i,j+1,diff+1));
        }
        if (diff>0) {
            if (i<s.length&&s[i] == ')') {
                if (j<t.length&&t[j] == ')') {
                    ans = Math.min(ans,1+ dp(i + 1, j + 1, diff - 1));
                } else {
                    ans = Math.min(ans, 1+dp(i + 1, j, diff - 1));
                }
            }
            if (j<t.length&&t[j] == ')') {
                ans = Math.min(ans,1+ dp(i, j + 1, diff - 1));
            }
        }
        return memo[i][j][diff]=ans;
    }
    static StringBuilder sol = new StringBuilder();
    static void  trace(int i,int j,int diff){
        if (i==s.length&&j==t.length) {
            while (diff-- > 0) sol.append(')');
            return;
        }
        int ans=dp(i,j,diff);
        if (ans==1+dp(i,j,diff+1)){
            sol.append('(');
            trace(i,j,diff+1);
            return;
        }
        if (i<s.length&&s[i]=='('){
            if (j<t.length&&t[j]=='('){
                if (ans==1+dp(i+1,j+1,diff+1)){
                    sol.append('(');
                    trace(i+1,j+1,diff+1);
                    return;
                }
            }
            else {
                if(ans==1+dp(i+1,j,diff+1)) {
                    sol.append('(');
                    trace(i+1,j,diff+1);
                return;
                }
            }
        }
        if (j<t.length&&t[j]=='('){
            if (ans==1+dp(i,j+1,diff+1)){
                sol.append('(');
                trace(i,j+1,diff+1);
            return;
            }
        }
        if (diff>0) {
            if (i<s.length&&s[i]==')'){
                if (j<t.length&&t[j]==')'){
                    if (ans==1+dp(i+1,j+1,diff-1)){
                        sol.append(')');
                        trace(i+1,j+1,diff-1);
                   return;
                    }
                }
                else {
                    if(ans==1+dp(i+1,j,diff-1)) {
                        sol.append(')');
                        trace(i+1,j,diff-1);
                    return;
                    }
                }
            }
            if (j<t.length&&t[j]==')'){
                if (ans==1+dp(i,j+1,diff-1)){
                    sol.append(')');
                    trace(i,j+1,diff-1);
            return;
                }
            }
        }
    }
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        s=sc.nextLine().toCharArray();
        t=sc.nextLine().toCharArray();
        memo=new int[s.length+1][t.length+1][500];
        for (int[][]x:memo)for (int[]z:x)Arrays.fill(z,-1);
        trace(0,0,0);
        pw.println(sol);
        pw.flush();
    }
    static class UnionFind {
        int[] p, rank, setSize;
        int numSets;
        HashSet<Integer>[]ele;
        public UnionFind(int N)
        {
            ele=new HashSet[N];
            p = new int[numSets = N];
            rank = new int[N];
            setSize = new int[N];
            for (int i = 0; i < N; i++) {
                ele[i]=new HashSet<>();
                p[i] = i; setSize[i] = 1;
                ele[i].add(i);
            }
        }

        public int findSet(int i) { return p[i] == i ? i : (p[i] = findSet(p[i])); }

        public boolean isSameSet(int i, int j) { return findSet(i) == findSet(j); }

        public void unionSet(int i, int j)
        {
            if (isSameSet(i, j))
                return;
            numSets--;
            int x = findSet(i), y = findSet(j);
            if(rank[x] > rank[y]) {
                for (int zz:ele[y])ele[x].add(zz);
                p[y] = x; setSize[x] += setSize[y]; }
            else
            {	for (int zz:ele[x])ele[y].add(zz);
                p[x] = y; setSize[y] += setSize[x];
                if(rank[x] == rank[y]) rank[y]++;
            }
        }

        public int numDisjointSets() { return numSets; }

        public int sizeOfSet(int i) { return setSize[findSet(i)]; }
    }
    static long gcd(long a, long b) {
        if (a == 0) return b;
        return gcd(b % a, a);
    }
    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

        public boolean ready() throws IOException {
            return br.ready();
        }
    }

}