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.

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 ')'.

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.

import java.io.*;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.stream.Collector;

@SuppressWarnings("Duplicates")
public class ProblemF {

    public static String s1,s2;
    public static final int INF = Integer.MAX_VALUE/2;
    public static int[][][][] memo = new int[205][205][205][4]; //0 val 1-3 parent
                                // s1 processed, s2 processed, bracket balance

    public static void main(String[] args) throws IOException{
        //Reader sc = new Reader();
        PrintWriter pw = new PrintWriter(System.out);
        //Scanner sc = new Scanner(System.in);
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        for (int i = 0; i < 205; i++) {
            for (int j = 0; j < 205; j++) {
                for (int k = 0; k < 205; k++) {
                    memo[i][j][k][0] = INF;
                }
            }
        }
        memo[0][0][0][0] = 0;
        s1 = br.readLine(); int l1 = s1.length();
        s2 = br.readLine(); int l2 = s2.length();

        for (int i = 0; i <= s1.length(); i++) {
            for (int j = 0; j <= s2.length(); j++) {
                for (int k = 0; k < 203; k++) {
                    if (memo[i][j][k][0]==INF) continue;
                    {//open bracket
                        if (i<l1 && j<l2 && s1.charAt(i)=='('&&s2.charAt(j)=='('){
                            if (memo[i+1][j+1][k+1][0] > memo[i][j][k][0]+1){
                                memo[i+1][j+1][k+1] = new int[] {memo[i][j][k][0]+1,i,j,k};
                                //setparent
                            }
                        } else if (i<l1 && s1.charAt(i)=='('){
                            if (memo[i+1][j][k+1][0] > memo[i][j][k][0]+1){
                                memo[i+1][j][k+1] = new int[] {memo[i][j][k][0]+1,i,j,k};
                                //setparent
                            }
                        } else if (j<l2 && s2.charAt(j)=='('){
                            if (memo[i][j+1][k+1][0] > memo[i][j][k][0]+1){
                                memo[i][j+1][k+1] = new int[] {memo[i][j][k][0]+1,i,j,k};
                                //setparent
                            }
                        } else {
                            if (memo[i][j][k+1][0] > memo[i][j][k][0]+1){
                                memo[i][j][k+1] = new int[] {memo[i][j][k][0]+1,i,j,k};
                            }
                        }
                    }
                    if (k>0) {//close bracket
                        if (i<l1 && j<l2 && s1.charAt(i)==')'&&s2.charAt(j)==')'){
                            if (memo[i+1][j+1][k-1][0] > memo[i][j][k][0]+1){
                                memo[i+1][j+1][k-1] = new int[] {memo[i][j][k][0]+1,i,j,k};
                                //setparent
                            }
                        } else if (i<l1 && s1.charAt(i)==')'){
                            if (memo[i+1][j][k-1][0] > memo[i][j][k][0]+1){
                                memo[i+1][j][k-1] = new int[] {memo[i][j][k][0]+1,i,j,k};
                                //setparent
                            }
                        } else if (j<l2 && s2.charAt(j)==')'){
                            if (memo[i][j+1][k-1][0] > memo[i][j][k][0]+1){
                                memo[i][j+1][k-1] = new int[] {memo[i][j][k][0]+1,i,j,k};
                                //setparent
                            }
                        } else {
                            if (memo[i][j][k-1][0] > memo[i][j][k][0]+1){
                                memo[i][j][k-1] = new int[] {memo[i][j][k][0]+1,i,j,k};
                            }
                        }
                    }
                }
            }
        }

        int bestK = 0;
        int bestVal = INF;
        for (int k = 0; k < 203; k++) {
            if (memo[l1][l2][k][0]+k < bestVal){
                bestVal = memo[l1][l2][k][0]+k;
                bestK = k;
            }
        }
        LinkedList<Character> sol = new LinkedList<>();
        for (int i = 0; i < bestK; i++) sol.add(')');
        int i = l1;
        int j = l2;
        int k = bestK;
        while (i != 0 || j != 0 || k != 0){
            int prevI = memo[i][j][k][1];
            int prevJ = memo[i][j][k][2];
            int prevK = memo[i][j][k][3];
            if (prevK < k)sol.addFirst('(');
            else sol.addFirst(')');
            i = prevI; j = prevJ; k = prevK;
        }

        pw.println(sol.stream().collect(Collector.of(StringBuilder::new,
                StringBuilder::append,
                StringBuilder::append,
                StringBuilder::toString)));

        pw.flush();
    }

    static class Reader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }
}

import java.io.*;
import java.util.*;

public class Main {
	static char[]in1;
	static char[]in2;
	static int[][][]memo;
	static int dp(int i,int j,int pref) {
		if(i>=in1.length) {
			int inc=0;
			while(j<in2.length) {
				pref+=in2[j]=='('?1:-1;
				inc++;
				if(pref<0) {
					pref=0;inc++;
				}
				j++;
			}
			return inc+pref;
		}
		if(j>=in2.length) {
			int inc=0;
			while(i<in1.length) {
				pref+=in1[i]=='('?1:-1;
				inc++;
				if(pref<0) {
					pref=0;inc++;
				}
				i++;
			}
			return inc+pref;
		}
		if(memo[i][j][pref]!=-1)return memo[i][j][pref];
		int f=in1[i]=='('?1:-1;
		int s=in2[j]=='('?1:-1;
		int ans=(int)1e7;
		if(pref+f<0) {
			ans=Math.min(ans, dp(i+1,j,0)+2);
		}
		else {
			ans=Math.min(ans, dp(i+1,j,pref+f)+1);
		}

		if(pref+s<0) {
			ans=Math.min(ans, dp(i,j+1,0)+2);
		}
		else {
			ans=Math.min(ans, dp(i,j+1,pref+s)+1);
		}

		if(s==f) {
			if(pref+s<0) {
				ans=Math.min(ans, dp(i+1,j+1,0)+2);
			}
			else {
				ans=Math.min(ans, dp(i+1,j+1,pref+s)+1);
			}
		}
		else {
			if(pref+f<0) {
				ans=Math.min(ans, dp(i+1,j+1,0)+3);
			}
			else {
				ans=Math.min(ans, dp(i+1,j+1,pref+f+s)+2);
			}

			if(pref+s<0) {
				ans=Math.min(ans, dp(i+1,j+1,0)+3);
			}
			else {
				ans=Math.min(ans, dp(i+1,j+1,pref+f+s)+2);
			}
		}
		return memo[i][j][pref]=ans;
	}
	static StringBuilder anss;
	static void trace(int i,int j,int pref) {
		if(i>=in1.length) {
			int inc=0;
			while(j<in2.length) {
				pref+=(in2[j]=='(')?1:-1;
				anss.append(in2[j]);
				if(pref<0) {
					pref=0;inc++;
				}
				j++;
			}
			StringBuilder ex=new StringBuilder();
			while(inc>0) {
				inc--;
				ex.append('(');
			}
			ex.append(anss);
			anss=new StringBuilder(ex);
			while(pref>0) {
				anss.append(')');pref--;
			}
			return;
		}
		if(j>=in2.length) {
			int inc=0;
			while(i<in1.length) {
				pref+=(in1[i]=='(')?1:-1;
				anss.append(in1[i]);
				if(pref<0) {
					pref=0;inc++;
				}
				i++;
			}
			StringBuilder ex=new StringBuilder();
			while(inc>0) {
				inc--;
				ex.append('(');
			}
			ex.append(anss);
			anss=new StringBuilder(ex);
			while(pref>0) {
				anss.append(')');pref--;
			}
			return;
		}
		int f=in1[i]=='('?1:-1;
		int s=in2[j]=='('?1:-1;
		int ans=dp(i,j,pref);
		if(pref+f<0) {
			if(ans==dp(i+1,j,0)+2) {
				anss.append(in1[i]);
				StringBuilder ex=new StringBuilder();ex.append('(');

				anss=new StringBuilder(ex.append(anss));
				trace(i+1,j,0);
				return;
			}
		}
		else {
			if(ans==dp(i+1,j,pref+f)+1) {
				anss.append(in1[i]);

				trace(i+1,j,pref+f);

				return;
			}
		}

		if(pref+s<0) {
			if(ans==dp(i,j+1,0)+2) {
				anss.append(in2[j]);
				StringBuilder ex=new StringBuilder();ex.append('(');

				anss=new StringBuilder(ex.append(anss));
				trace(i,j+1,0);
				return;
			}
		}
		else {
			if(ans==dp(i,j+1,pref+s)+1) {
				anss.append(in2[j]);

				trace(i,j+1,pref+s);
				return;
			}
		}

		if(s==f) {
			if(pref+s<0) {
				if(ans==dp(i+1,j+1,0)+2) {
					//System.out.println(i+" "+j);
					anss.append(in2[j]);
					StringBuilder ex=new StringBuilder();ex.append('(');

					anss=new StringBuilder(ex.append(anss));
					trace(i+1,j+1,0);
					return;
				}
			}
			else {
				if(ans==dp(i+1,j+1,pref+s)+1) {
					anss.append(in2[j]);

					trace(i+1,j+1,pref+s);
					return;
				}
			}
		}
		else {
			if(pref+f<0) {
				if(ans==dp(i+1,j+1,0)+3) {
					anss.append(in1[i]+""+in2[j]);
					StringBuilder ex=new StringBuilder();ex.append('(');

					anss=new StringBuilder(ex.append(anss));
					trace(i+1,j+1,0);
					return;
				}
			}
			else {
				if(ans==dp(i+1,j+1,pref+s+f)+2) {
					anss.append(in1[i]+""+in2[j]);

					trace(i+1,j+1,pref+s+f);
					return;
				}
			}

			if(pref+s<0) {
				if(ans==dp(i+1,j+1,0)+3) {
					anss.append(in2[j]+""+in1[i]);
					StringBuilder ex=new StringBuilder();ex.append('(');

					anss=new StringBuilder(ex.append(anss));
					trace(i+1,j+1,0);
					return;
				}
			}
			else {
				if(ans==dp(i+1,j+1,pref+s+f)+2) {
					anss.append(in2[j]+""+in1[i]);

					trace(i+1,j+1,pref+s+f);
				}
			}

		}
	}
	public static void main(String[] args) throws Exception {
		MScanner sc = new MScanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		in1=sc.nextLine().toCharArray();
		in2=sc.nextLine().toCharArray();
		memo=new int[in1.length][in2.length][Math.max(in1.length, in2.length)+1];
		for(int [][]i:memo) {
			for(int j[]:i) {
				Arrays.fill(j, -1);
			}
		}
		anss=new StringBuilder();

		trace(0,0,0);
		pw.println(anss);
		pw.flush();
	}
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;

		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

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

		public int[] takearr(int n) throws IOException {
			int[] in = new int[n];
			for (int i = 0; i < n; i++)
				in[i] = nextInt();
			return in;
		}

		public long[] takearrl(int n) throws IOException {
			long[] in = new long[n];
			for (int i = 0; i < n; i++)
				in[i] = nextLong();
			return in;
		}

		public Integer[] takearrobj(int n) throws IOException {
			Integer[] in = new Integer[n];
			for (int i = 0; i < n; i++)
				in[i] = nextInt();
			return in;
		}

		public Long[] takearrlobj(int n) throws IOException {
			Long[] in = new Long[n];
			for (int i = 0; i < n; i++)
				in[i] = nextLong();
			return in;
		}

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

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

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

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

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

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

import java.io.*;
import java.util.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class cf1272f {

    public static void main(String[] args) throws IOException {
        char[] s = rcha(), t = rcha();
        int n = s.length, m = t.length, dp[][][] = new int[n + 1][m + 1][201], last[][][][] = new int[n + 1][m + 1][201][3];
        for (int[][] layer : dp) {
            for (int[] row : layer) {
                fill(row, IBIG);
            }
        }
        dp[0][0][0] = 0;
        for (int i = 0; i <= n; ++i) {
            for (int j = 0; j <= m; ++j) {
                for (int k = 0; k <= 200; ++k) {
                    int ni = i + (i < n && s[i] == '(' ? 1 : 0), nj = j + (j < m && t[j] == '(' ? 1 : 0);
                    if (k < 200 && dp[i][j][k] + 1 < dp[ni][nj][k + 1]) {
                        dp[ni][nj][k + 1] = dp[i][j][k] + 1;
                        last[ni][nj][k + 1][0] = i;
                        last[ni][nj][k + 1][1] = j;
                        last[ni][nj][k + 1][2] = k;
                    }
                    ni = i + (i < n && s[i] == ')' ? 1 : 0);
                    nj = j + (j < m && t[j] == ')' ? 1 : 0);
                    if (k > 0 && dp[i][j][k] + 1 < dp[ni][nj][k - 1]) {
                        dp[ni][nj][k - 1] = dp[i][j][k] + 1;
                        last[ni][nj][k - 1][0] = i;
                        last[ni][nj][k - 1][1] = j;
                        last[ni][nj][k - 1][2] = k;
                    }
                }
            }
        }
        int min_ind = 0;
        for (int i = 1; i <= 200; ++i) {
            if (dp[n][m][i] + i < dp[n][m][min_ind] + min_ind) {
                min_ind = i;
            }
        }
        char[] ans = new char[dp[n][m][min_ind] + min_ind];
        for (int i = dp[n][m][min_ind]; i < ans.length; ++i) {
            ans[i] = ')';
        }
        // prln(min_ind);
        int curi = n, curj = m, curbal = min_ind;
        for (int i = dp[n][m][min_ind] - 1; i >= 0; --i) {
            int[] last_state = last[curi][curj][curbal];
            ans[i] = last_state[2] < curbal ? '(' : ')';
            curi = last_state[0];
            curj = last_state[1];
            curbal = last_state[2];
        }
        prln(ans);
        close();
    }

    static BufferedReader __in = new BufferedReader(new InputStreamReader(System.in));
    static PrintWriter __out = new PrintWriter(new OutputStreamWriter(System.out));
    static StringTokenizer input;
    static Random __rand = new Random();

    // references
    // IBIG = 1e9 + 7
    // IMAX ~= 2e9
    // LMAX ~= 9e18

    // constants
    static final int IBIG = 1000000007;
    static final int IMAX = 2147483647;
    static final int IMIN = -2147483648;
    static final long LMAX = 9223372036854775807L;
    static final long LMIN = -9223372036854775808L;
    // math util
    static int minof(int a, int b, int c) {return min(a, min(b, c));}
    static int minof(int... x) {if (x.length == 1) return x[0]; if (x.length == 2) return min(x[0], x[1]); if (x.length == 3) return min(x[0], min(x[1], x[2])); int min = x[0]; for (int i = 1; i < x.length; ++i) if (x[i] < min) min = x[i]; return min;}
    static long minof(long a, long b, long c) {return min(a, min(b, c));}
    static long minof(long... x) {if (x.length == 1) return x[0]; if (x.length == 2) return min(x[0], x[1]); if (x.length == 3) return min(x[0], min(x[1], x[2])); long min = x[0]; for (int i = 1; i < x.length; ++i) if (x[i] < min) min = x[i]; return min;}
    static int maxof(int a, int b, int c) {return max(a, max(b, c));}
    static int maxof(int... x) {if (x.length == 1) return x[0]; if (x.length == 2) return max(x[0], x[1]); if (x.length == 3) return max(x[0], max(x[1], x[2])); int max = x[0]; for (int i = 1; i < x.length; ++i) if (x[i] > max) max = x[i]; return max;}
    static long maxof(long a, long b, long c) {return max(a, max(b, c));}
    static long maxof(long... x) {if (x.length == 1) return x[0]; if (x.length == 2) return max(x[0], x[1]); if (x.length == 3) return max(x[0], max(x[1], x[2])); long max = x[0]; for (int i = 1; i < x.length; ++i) if (x[i] > max) max = x[i]; return max;}
    static int powi(int a, int b) {if (a == 0) return 0; int ans = 1; while (b > 0) {if ((b & 1) > 0) ans *= a; a *= a; b >>= 1;} return ans;}
    static long powl(long a, int b) {if (a == 0) return 0; long ans = 1; while (b > 0) {if ((b & 1) > 0) ans *= a; a *= a; b >>= 1;} return ans;}
    static int fli(double d) {return (int) d;}
    static int cei(double d) {return (int) ceil(d);}
    static long fll(double d) {return (long) d;}
    static long cel(double d) {return (long) ceil(d);}
    static int gcf(int a, int b) {return b == 0 ? a : gcf(b, a % b);}
    static long gcf(long a, long b) {return b == 0 ? a : gcf(b, a % b);}
    static int lcm(int a, int b) {return a * b / gcf(a, b);}
    static long lcm(long a, long b) {return a * b / gcf(a, b);}
    static int randInt(int min, int max) {return __rand.nextInt(max - min + 1) + min;}
    static long mix(long x) {x += 0x9e3779b97f4a7c15L; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9L; x = (x ^ (x >> 27)) * 0x94d049bb133111ebL; return x ^ (x >> 31);}
    // array util
    static void reverse(int[] a) {for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {int swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}}
    static void reverse(long[] a) {for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {long swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}}
    static void reverse(double[] a) {for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {double swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}}
    static void reverse(char[] a) {for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {char swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}}
    static void shuffle(int[] a) {int n = a.length - 1; for (int i = 0; i < n; ++i) {int ind = randInt(i, n); int swap = a[i]; a[i] = a[ind]; a[ind] = swap;}}
    static void shuffle(long[] a) {int n = a.length - 1; for (int i = 0; i < n; ++i) {int ind = randInt(i, n); long swap = a[i]; a[i] = a[ind]; a[ind] = swap;}}
    static void shuffle(double[] a) {int n = a.length - 1; for (int i = 0; i < n; ++i) {int ind = randInt(i, n); double swap = a[i]; a[i] = a[ind]; a[ind] = swap;}}
    static void rsort(int[] a) {shuffle(a); sort(a);}
    static void rsort(long[] a) {shuffle(a); sort(a);}
    static void rsort(double[] a) {shuffle(a); sort(a);}
    static int[] copy(int[] a) {int[] ans = new int[a.length]; for (int i = 0; i < a.length; ++i) ans[i] = a[i]; return ans;}
    static long[] copy(long[] a) {long[] ans = new long[a.length]; for (int i = 0; i < a.length; ++i) ans[i] = a[i]; return ans;}
    static double[] copy(double[] a) {double[] ans = new double[a.length]; for (int i = 0; i < a.length; ++i) ans[i] = a[i]; return ans;}
    static char[] copy(char[] a) {char[] ans = new char[a.length]; for (int i = 0; i < a.length; ++i) ans[i] = a[i]; return ans;}
    // graph util
    static List<List<Integer>> g(int n) {List<List<Integer>> g = new ArrayList<>(); for (int i = 0; i < n; ++i) g.add(new ArrayList<>()); return g;}
    static List<Set<Integer>> sg(int n) {List<Set<Integer>> g = new ArrayList<>(); for (int i = 0; i < n; ++i) g.add(new HashSet<>()); return g;}
    static void c(List<? extends Collection<Integer>> g, int u, int v) {g.get(u).add(v); g.get(v).add(u);}
    static void cto(List<? extends Collection<Integer>> g, int u, int v) {g.get(u).add(v);}
    static void dc(List<? extends Collection<Integer>> g, int u, int v) {g.get(u).remove(v); g.get(v).remove(u);}
    static void dcto(List<? extends Collection<Integer>> g, int u, int v) {g.get(u).remove(v);}
    // input
    static void r() throws IOException {input = new StringTokenizer(rline());}
    static int ri() throws IOException {return Integer.parseInt(rline());}
    static long rl() throws IOException {return Long.parseLong(rline());}
    static double rd() throws IOException {return Double.parseDouble(rline());}
    static int[] ria(int n) throws IOException {int[] a = new int[n]; r(); for (int i = 0; i < n; ++i) a[i] = ni(); return a;}
    static int[] riam1(int n) throws IOException {int[] a = new int[n]; r(); for (int i = 0; i < n; ++i) a[i] = ni() - 1; return a;}
    static long[] rla(int n) throws IOException {long[] a = new long[n]; r(); for (int i = 0; i < n; ++i) a[i] = nl(); return a;}
    static double[] rda(int n) throws IOException {double[] a = new double[n]; r(); for (int i = 0; i < n; ++i) a[i] = nd(); return a;}
    static char[] rcha() throws IOException {return rline().toCharArray();}
    static String rline() throws IOException {return __in.readLine();}
    static String n() {return input.nextToken();}
    static int rni() throws IOException {r(); return ni();}
    static int ni() {return Integer.parseInt(n());}
    static long rnl() throws IOException {r(); return nl();}
    static long nl() {return Long.parseLong(n());}
    static double rnd() throws IOException {r(); return nd();}
    static double nd() {return Double.parseDouble(n());}
    static List<List<Integer>> rg(int n, int m) throws IOException {List<List<Integer>> g = g(n); for (int i = 0; i < m; ++i) c(g, rni() - 1, ni() - 1); return g;}
    static void rg(List<List<Integer>> g, int m) throws IOException {for (int i = 0; i < m; ++i) c(g, rni() - 1, ni() - 1);}
    static List<List<Integer>> rdg(int n, int m) throws IOException {List<List<Integer>> g = g(n); for (int i = 0; i < m; ++i) cto(g, rni() - 1, ni() - 1); return g;}
    static void rdg(List<List<Integer>> g, int m) throws IOException {for (int i = 0; i < m; ++i) cto(g, rni() - 1, ni() - 1);}
    static List<Set<Integer>> rsg(int n, int m) throws IOException {List<Set<Integer>> g = sg(n); for (int i = 0; i < m; ++i) c(g, rni() - 1, ni() - 1); return g;}
    static void rsg(List<Set<Integer>> g, int m) throws IOException {for (int i = 0; i < m; ++i) c(g, rni() - 1, ni() - 1);}
    static List<Set<Integer>> rdsg(int n, int m) throws IOException {List<Set<Integer>> g = sg(n); for (int i = 0; i < m; ++i) cto(g, rni() - 1, ni() - 1); return g;}
    static void rdsg(List<Set<Integer>> g, int m) throws IOException {for (int i = 0; i < m; ++i) cto(g, rni() - 1, ni() - 1);}
    // output
    static void pr(int i) {__out.print(i);}
    static void prln(int i) {__out.println(i);}
    static void pr(long l) {__out.print(l);}
    static void prln(long l) {__out.println(l);}
    static void pr(double d) {__out.print(d);}
    static void prln(double d) {__out.println(d);}
    static void pr(char c) {__out.print(c);}
    static void prln(char c) {__out.println(c);}
    static void pr(char[] s) {__out.print(new String(s));}
    static void prln(char[] s) {__out.println(new String(s));}
    static void pr(String s) {__out.print(s);}
    static void prln(String s) {__out.println(s);}
    static void pr(Object o) {__out.print(o);}
    static void prln(Object o) {__out.println(o);}
    static void prln() {__out.println();}
    static void pryes() {prln("yes");}
    static void pry() {prln("Yes");}
    static void prY() {prln("YES");}
    static void prno() {prln("no");}
    static void prn() {prln("No");}
    static void prN() {prln("NO");}
    static void pryesno(boolean b) {prln(b ? "yes" : "no");};
    static void pryn(boolean b) {prln(b ? "Yes" : "No");}
    static void prYN(boolean b) {prln(b ? "YES" : "NO");}
    static void prln(int... a) {for (int i = 0, len = a.length - 1; i < len; pr(a[i]), pr(' '), ++i); if (a.length > 0) prln(a[a.length - 1]); else prln();}
    static void prln(long... a) {for (int i = 0, len = a.length - 1; i < len; pr(a[i]), pr(' '), ++i); if (a.length > 0) prln(a[a.length - 1]); else prln();}
    static void prln(double... a) {for (int i = 0, len = a.length - 1; i < len; pr(a[i]), pr(' '), ++i); if (a.length > 0) prln(a[a.length - 1]); else prln();}
    static <T> void prln(Collection<T> c) {int n = c.size() - 1; Iterator<T> iter = c.iterator(); for (int i = 0; i < n; pr(iter.next()), pr(' '), ++i); if (n >= 0) prln(iter.next()); else prln();}
    static void h() {prln("hlfd"); flush();}
    static void flush() {__out.flush();}
    static void close() {__out.close();}}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author gaidash
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        FDveSkobochniePosledovatelnosti solver = new FDveSkobochniePosledovatelnosti();
        solver.solve(1, in, out);
        out.close();
    }

    static class FDveSkobochniePosledovatelnosti {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            final int INF = Integer.MAX_VALUE;
            final int MAX_BAL = 202;

            String s1 = in.nextString();
            String s2 = in.nextString();
            int n1 = s1.length();
            int n2 = s2.length();
            int[][][] dp = new int[MAX_BAL][n1 + 1][n2 + 1];
            for (int bal = 0; bal < MAX_BAL; bal++) {
                for (int i = 0; i <= n1; i++) {
                    for (int j = 0; j <= n2; j++) {
                        dp[bal][i][j] = INF;
                    }
                }
            }
            dp[0][0][0] = 0;
            FDveSkobochniePosledovatelnosti.Elem[][][] prev = new FDveSkobochniePosledovatelnosti.Elem[MAX_BAL][n1 + 1][n2 + 1];
            for (int i = 0; i <= n1; i++) {
                for (int j = 0; j <= n2; j++) {
                    for (int bal = 0; bal < MAX_BAL; bal++) {
                        if (dp[bal][i][j] == INF) {
                            continue;
                        }
                        for (char bracket : new char[]{'(', ')'}) {
                            int nextI = i + (i < n1 && s1.charAt(i) == bracket ? 1 : 0);
                            int nextJ = j + (j < n2 && s2.charAt(j) == bracket ? 1 : 0);
                            int nextBal = bal + (bracket == '(' ? 1 : -1);
                            if (nextBal < 0 || nextBal >= MAX_BAL) {
                                continue;
                            }
                            if (dp[bal][i][j] + 1 < dp[nextBal][nextI][nextJ]) {
                                dp[nextBal][nextI][nextJ] = dp[bal][i][j] + 1;
                                prev[nextBal][nextI][nextJ] = new FDveSkobochniePosledovatelnosti.Elem(i, j, bracket, bal);
                            }
                        }
                    }
                }
            }
            int best = INF;
            int curBal = -1;
            int curI = n1;
            int curJ = n2;
            for (int bal = 0; bal < MAX_BAL; bal++) {
                if (best > dp[bal][n1][n2] + bal) {
                    best = dp[bal][n1][n2];
                    curBal = bal;
                }
            }
            int add = curBal;
            StringBuilder ret = new StringBuilder();
            while (curBal > 0 || curI > 0 || curJ > 0) {
                FDveSkobochniePosledovatelnosti.Elem e = prev[curBal][curI][curJ];
                ret.append(e.bracket);
                curBal = e.bal;
                curI = e.i;
                curJ = e.j;
            }
            ret.reverse().append(")".repeat(add));
            out.println(ret);
        }

        private static class Elem {
            private int i;
            private int j;
            private char bracket;
            private int bal;

            private Elem(int i, int j, char bracket, int bal) {
                this.i = i;
                this.j = j;
                this.bracket = bracket;
                this.bal = bal;
            }

        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public String nextString() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                if (Character.isValidCodePoint(c)) {
                    res.appendCodePoint(c);
                }
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void println(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

    }
}

import java.io.BufferedOutputStream;
import java.io.Closeable;
import java.io.DataInputStream;
import java.io.Flushable;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.InputMismatchException;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	static class TaskAdapter implements Runnable {
		@Override
		public void run() {
			InputStream inputStream = System.in;
			OutputStream outputStream = System.out;
			FastReader in = new FastReader(inputStream);
			Output out = new Output(outputStream);
			FTwoBracketSequences solver = new FTwoBracketSequences();
			solver.solve(1, in, out);
			out.close();
		}
	}

	public static void main(String[] args) throws Exception {
		Thread thread = new Thread(null, new TaskAdapter(), "", 1<<28);
		thread.start();
		thread.join();
	}

	static class FTwoBracketSequences {
		private final int iinf = 1_000_000_000;

		public FTwoBracketSequences() {
		}

		private int get(char c) {
			return c=='(' ? 1 : 0;
		}

		public void solve(int kase, InputReader in, Output pw) {
			String sa = in.next(200), sb = in.next(200);
			int n = sa.length(), m = sb.length();
			int[][] a = new int[n+1][2], b = new int[m+1][2];
			for(int i = 0; i<n; i++) {
				a[i][get(sa.charAt(i))] = 1;
			}
			for(int i = 0; i<m; i++) {
				b[i][get(sb.charAt(i))] = 1;
			}
			int[][][] dp = new int[n+1][m+1][201], next = new int[n+1][m+1][201];
			for(int i = 0; i<=200; i++) {
				dp[n][m][i] = i;
			}
			for(int i = n; i>=0; i--) {
				for(int j = m-(i==n ? 1 : 0); j>=0; j--) {
					for(int k = 1; k<200; k++) {
						dp[i][j][k] = iinf;
						if(a[i][0]>0||b[j][0]>0) {
							dp[i][j][k] = dp[i+a[i][0]][j+b[j][0]][k-1];
							next[i][j][k] = -1;
						}
						if((a[i][1]>0||b[j][1]>0)&&dp[i+a[i][1]][j+b[j][1]][k+1]<dp[i][j][k]) {
							dp[i][j][k] = dp[i+a[i][1]][j+b[j][1]][k+1];
							next[i][j][k] = 1;
						}
						dp[i][j][k]++;
					}
					next[i][j][0] = 1;
					dp[i][j][0] = 1+dp[i+a[i][1]][j+b[j][1]][1];
					next[i][j][200] = -1;
					dp[i][j][200] = 1+dp[i+a[i][0]][j+b[j][0]][199];
				}
			}
			int i = 0, j = 0, k = 0;
			while(i<n||j<m) {
				pw.print(next[i][j][k]==1 ? "(" : ")");
				int x = Math.max(next[i][j][k], 0);
				k += next[i][j][k];
				i += a[i][x];
				j += b[j][x];
			}
			pw.println(")".repeat(k));
		}

	}

	static interface InputReader {
		String next();

		default String next(int maxLength) {
			return next();
		}

	}

	static class FastReader implements InputReader {
		final private int BUFFER_SIZE = 1<<16;
		private DataInputStream din;
		private byte[] buffer;
		private int bufferPointer;
		private int bytesRead;

		public FastReader(InputStream is) {
			din = new DataInputStream(is);
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public String next() {
			StringBuilder ret = new StringBuilder(64);
			byte c = skip();
			while(c!=-1&&!isSpaceChar(c)) {
				ret.appendCodePoint(c);
				c = read();
			}
			return ret.toString();
		}

		public String next(int maxLength) {
			byte[] ret = new byte[maxLength];
			byte c = skip();
			int ind = 0;
			while(c!=-1&&!isSpaceChar(c)) {
				ret[ind++] = c;
				c = read();
			}
			return new String(ret, 0, ind);
		}

		private boolean isSpaceChar(byte b) {
			return b==' '||b=='\r'||b=='\n'||b=='\t'||b=='\f';
		}

		private byte skip() {
			byte ret;
			while(isSpaceChar((ret = read()))) ;
			return ret;
		}

		private void fillBuffer() {
			try {
				bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
			}catch(IOException e) {
				e.printStackTrace();
				throw new InputMismatchException();
			}
			if(bytesRead==-1) {
				buffer[0] = -1;
			}
		}

		private byte read() {
			if(bytesRead==-1) {
				throw new InputMismatchException();
			}else if(bufferPointer==bytesRead) {
				fillBuffer();
			}
			return buffer[bufferPointer++];
		}

	}

	static class Output implements Closeable, Flushable {
		public StringBuilder sb;
		public OutputStream os;
		public int BUFFER_SIZE;
		public String lineSeparator;

		public Output(OutputStream os) {
			this(os, 1<<16);
		}

		public Output(OutputStream os, int bs) {
			BUFFER_SIZE = bs;
			sb = new StringBuilder(BUFFER_SIZE);
			this.os = new BufferedOutputStream(os, 1<<17);
			lineSeparator = System.lineSeparator();
		}

		public void print(String s) {
			sb.append(s);
			if(sb.length()>BUFFER_SIZE >> 1) {
				flushToBuffer();
			}
		}

		public void println(String s) {
			sb.append(s);
			println();
		}

		public void println() {
			sb.append(lineSeparator);
		}

		private void flushToBuffer() {
			try {
				os.write(sb.toString().getBytes());
			}catch(IOException e) {
				e.printStackTrace();
			}
			sb = new StringBuilder(BUFFER_SIZE);
		}

		public void flush() {
			try {
				flushToBuffer();
				os.flush();
			}catch(IOException e) {
				e.printStackTrace();
			}
		}

		public void close() {
			flush();
			try {
				os.close();
			}catch(IOException e) {
				e.printStackTrace();
			}
		}

	}
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.util.Collection;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.Queue;
import java.util.ArrayDeque;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Rustam Musin (t.me/musin_acm)
 */
public class Main {
  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    OutputWriter out = new OutputWriter(outputStream);
    FDveSkobochniePosledovatelnosti solver = new FDveSkobochniePosledovatelnosti();
    solver.solve(1, in, out);
    out.close();
  }

  static class FDveSkobochniePosledovatelnosti {
    int maxOpened;
    char[] s;
    char[] t;
    int n;
    int m;
    int[][][] dp;
    FDveSkobochniePosledovatelnosti.State[][][] parent;
    Queue<FDveSkobochniePosledovatelnosti.State> q;

    public void solve(int testNumber, InputReader in, OutputWriter out) {
      s = in.next().toCharArray();
      t = in.next().toCharArray();
      n = s.length;
      m = t.length;
      maxOpened = n + m;
      dp = new int[n + 1][m + 1][maxOpened + 1];
      ArrayUtils.fill(dp, -1);
      parent = new FDveSkobochniePosledovatelnosti.State[n + 1][m + 1][maxOpened + 1];
      q = new ArrayDeque<>();
      q.add(new FDveSkobochniePosledovatelnosti.State(0, 0, 0));
      dp[0][0][0] = 0;
      while (!q.isEmpty()) {
        FDveSkobochniePosledovatelnosti.State cur = q.poll();
        update(cur, true);
        update(cur, false);
      }
      FDveSkobochniePosledovatelnosti.State last = new FDveSkobochniePosledovatelnosti.State(n, m, 0);
      int len = dp[last.at0][last.at1][last.balance];
      char[] res = new char[len];
      for (int i = 0; i < len; i++) {
        FDveSkobochniePosledovatelnosti.State prev = parent[last.at0][last.at1][last.balance];
        char c = prev.balance < last.balance ? '(' : ')';
        res[len - i - 1] = c;
        last = prev;
      }
      out.print(res);
    }

    void update(FDveSkobochniePosledovatelnosti.State curState, boolean open) {
      int at0 = curState.at0;
      int at1 = curState.at1;
      int balance = curState.balance;
      int path = dp[at0][at1][balance];
      int newBalance = balance + (open ? 1 : -1);
      if (newBalance < 0 || newBalance > maxOpened) return;
      char c = open ? '(' : ')';
      int AT0 = at0;
      int AT1 = at1;
      if (at0 < n && s[at0] == c) AT0++;
      if (at1 < m && t[at1] == c) AT1++;
      if (dp[AT0][AT1][newBalance] == -1) {
        dp[AT0][AT1][newBalance] = path + 1;
        parent[AT0][AT1][newBalance] = curState;
        q.add(new FDveSkobochniePosledovatelnosti.State(AT0, AT1, newBalance));
      }
    }

    static class State {
      int at0;
      int at1;
      int balance;

      State(int at0, int at1, int balance) {
        this.at0 = at0;
        this.at1 = at1;
        this.balance = balance;
      }

    }

  }

  static class OutputWriter {
    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
      writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public OutputWriter(Writer writer) {
      this.writer = new PrintWriter(writer);
    }

    public void print(char[] array) {
      writer.print(array);
    }

    public void close() {
      writer.close();
    }

  }

  static class InputReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private InputReader.SpaceCharFilter filter;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public int read() {
      if (numChars == -1) {
        throw new InputMismatchException();
      }
      if (curChar >= numChars) {
        curChar = 0;
        try {
          numChars = stream.read(buf);
        } catch (IOException e) {
          throw new InputMismatchException();
        }
        if (numChars <= 0) {
          return -1;
        }
      }
      return buf[curChar++];
    }

    public String readString() {
      int c = read();
      while (isSpaceChar(c)) {
        c = read();
      }
      StringBuilder res = new StringBuilder();
      do {
        if (Character.isValidCodePoint(c)) {
          res.appendCodePoint(c);
        }
        c = read();
      } while (!isSpaceChar(c));
      return res.toString();
    }

    public boolean isSpaceChar(int c) {
      if (filter != null) {
        return filter.isSpaceChar(c);
      }
      return isWhitespace(c);
    }

    public static boolean isWhitespace(int c) {
      return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public String next() {
      return readString();
    }

    public interface SpaceCharFilter {
      public boolean isSpaceChar(int ch);

    }

  }

  static class ArrayUtils {
    public static void fill(int[][] array, int value) {
      for (int[] row : array) {
        Arrays.fill(row, value);
      }
    }

    public static void fill(int[][][] array, int value) {
      for (int[][] subArray : array) {
        fill(subArray, value);
      }
    }

  }
}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.*;

public class TwoBracketSequences {

	static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
	static BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

	static char[] s, t;
	static final int N = 202, INF = 404;

	static parent parent(int x, int y, int bal, char c) {
		return new parent(x, y, bal, c);
	}

	static class parent {
		int x;
		int y;
		int bal;
		char c;

		public parent(int x, int y, int bal, char c) {
			super();
			this.x = x;
			this.y = y;
			this.bal = bal;
			this.c = c;
		}
	}

	static void process() throws Exception {
		int n = s.length, m = t.length;
		int[][][] dp = new int[n + 1][m + 1][N];
		parent[][][] p = new parent[n + 1][m + 1][N];

		for (int i = 0; i <= n; i++) {
			for (int j = 0; j <= m; j++) {
				Arrays.fill(dp[i][j], INF);
			}
		}

		dp[0][0][0] = 0;
		for (int i = 0; i <= n; i++) {
			for (int j = 0; j <= m; j++) {
				for (int bal = 0; bal < N; bal++) {
					if (dp[i][j][bal] == INF) {
						continue;
					}
					int nxti = i + ((i < n && (s[i] == '(')) ? 1 : 0);
					int nxtj = j + ((j < m && (t[j] == '(')) ? 1 : 0);

//					System.out.println(nxti + " " + nxtj + " " + bal + " dp");

					if (bal + 1 < N && (dp[nxti][nxtj][bal + 1] > dp[i][j][bal] + 1)) {
						dp[nxti][nxtj][bal + 1] = dp[i][j][bal] + 1;
						p[nxti][nxtj][bal + 1] = parent(i, j, bal, '(');
					}

					nxti = i + ((i < n && (s[i] == ')')) ? 1 : 0);
					nxtj = j + ((j < m && (t[j] == ')')) ? 1 : 0);

//					System.out.println(nxti + " " + nxtj + " " + bal + " dp");

					if (bal > 0 && (dp[nxti][nxtj][bal - 1] > dp[i][j][bal] + 1)) {
						dp[nxti][nxtj][bal - 1] = dp[i][j][bal] + 1;
						p[nxti][nxtj][bal - 1] = parent(i, j, bal, ')');
					}
				}
			}
		}

		int curbal = 0;
		for (int bal = 0; bal < N; bal++) {
			if (dp[n][m][bal] + bal < dp[n][m][curbal] + curbal) {
				curbal = bal;
			}
		}

		int ci = n, cj = m;
		StringBuilder builder = new StringBuilder();
		for (int i = 0; i < curbal; i++) {
			builder.append(')');
		}
		while (ci > 0 || cj > 0 || curbal != 0) {
//			System.out.println(ci + " " + cj + " " + curbal);
			parent par = p[ci][cj][curbal];
			ci = par.x;
			cj = par.y;
			curbal = par.bal;
			builder.append(par.c);
		}
		writer.write(builder.reverse().toString());
		writer.newLine();
	}

	public static void main(String[] args) throws Exception {
		//		writer = new BufferedWriter(new FileWriter("output.txt"));
		String data[], input;
		s = reader.readLine().toCharArray();
		t = reader.readLine().toCharArray();
		process();
		writer.close();
	}

}

import java.io.*;
import java.lang.reflect.Array;
import java.util.*;

import static java.lang.Math.*;

public class Main {
    int N = 202;
    int INF = Integer.MAX_VALUE / 2;

    void run() throws IOException {
        char[] a = next().toCharArray();
        char[] b = next().toCharArray();
        int n = a.length;
        int m = b.length;
        point[][][] p = new point[n + 1][m + 1][2 * N];
        int[][][] dp = new int[n + 1][m + 1][2 * N];
        for (int i = 0; i <= n; ++i) {
            for (int j = 0; j <= m; ++j) {
                for (int bal = 0; bal < 2 * N; ++bal) {
                    dp[i][j][bal] = INF;
                }
            }
        }

        dp[0][0][0] = 0;
        for (int i = 0; i <= n; ++i) {
            for (int j = 0; j <= m; ++j) {
                for (int bal = 0; bal < 2 * N; ++bal) {
                    if (dp[i][j][bal] == INF) continue;
                    int nxti = i + (i < n && a[i] == '(' ? 1 : 0);
                    int nxtj = j + (j < m && b[j] == '(' ? 1 : 0);
                    if (bal + 1 < 2 * N && dp[nxti][nxtj][bal + 1] > dp[i][j][bal] + 1) {
                        dp[nxti][nxtj][bal + 1] = dp[i][j][bal] + 1;
                        p[nxti][nxtj][bal + 1] = new point(i, j, bal, '(');
                    }
                    nxti = i + (i < n && a[i] == ')' ? 1 : 0);
                    nxtj = j + (j < m && b[j] == ')' ? 1 : 0);
                    if (bal > 0 && dp[nxti][nxtj][bal - 1] > dp[i][j][bal] + 1) {
                        dp[nxti][nxtj][bal - 1] = dp[i][j][bal] + 1;
                        p[nxti][nxtj][bal - 1] = new point(i, j, bal, ')');
                    }
                }
            }
        }

        int ci = n, cj = m, cbal = 0;
        for (int bal = 0; bal < 2 * N; ++bal) {
            if (dp[n][m][bal] + bal < dp[n][m][cbal] + cbal) {
                cbal = bal;
            }
        }
        String res = "";
        for (int i = 0; i < cbal; i++) {
            res += ')';
        }
        while (ci > 0 || cj > 0 || cbal != 0) {
            int nci = p[ci][cj][cbal].a;
            int ncj = p[ci][cj][cbal].b;
            int ncbal = p[ci][cj][cbal].c;
            res += p[ci][cj][cbal].d;
            ci = nci;
            cj = ncj;
            cbal = ncbal;
        }
        char[] x = res.toCharArray();
        int l = 0;
        int r = x.length - 1;
        while (l < r) {
            char s = x[l];
            x[l] = x[r];
            x[r] = s;
            l++;
            r--;
        }
        for (int i = 0; i < x.length; i++) {
            pw.print(x[i]);
        }
        pw.close();
    }

    class point {
        int a, b, c;
        char d;

        public point(int a, int b, int c, char d) {
            this.a = a;
            this.b = b;
            this.c = c;
            this.d = d;
        }
    }

    long mod = (long) 1e9 + 7;
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    //BufferedReader br = new BufferedReader(new FileReader("qual.in"));

    StringTokenizer st = new StringTokenizer("");
    PrintWriter pw = new PrintWriter(System.out);
    //PrintWriter pw = new PrintWriter("qual.out");

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

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

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

    double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    public Main() throws FileNotFoundException {
    }

    public static void main(String[] args) throws IOException {
        new Main().run();
    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        FTwoBracketSequences solver = new FTwoBracketSequences();
        solver.solve(1, in, out);
        out.close();
    }

    static class FTwoBracketSequences {
        static char[] first;
        static char[] second;
        static Integer[][][] memo;
        static StringBuilder s = new StringBuilder();

        public static int dp(int i, int j, int k) {
            if (i == first.length && second.length == j)
                return k;
            if (memo[i][j][k] != null)
                return memo[i][j][k];
            if (k == 0) {
                int ans;
                if (first.length > i && j < second.length && first[i] == '(' & second[j] == '(')
                    ans = 1 + dp(i + 1, j + 1, 1);
                else if (i < first.length && first[i] == '(')
                    ans = 1 + dp(i + 1, j, 1);
                else if (j < second.length && second[j] == '(')
                    ans = 1 + dp(i, j + 1, 1);
                else
                    ans = 1 + dp(i, j, 1);
                return memo[i][j][k] = ans;
            } else {
                if (i < first.length && j < second.length && first[i] == second[j]) {
                    int open = first[i] == '(' ? 1 + dp(i + 1, j + 1, k + 1) : 1 + dp(i + 1, j + 1, k - 1);
                    return memo[i][j][k] = open;
                } else {
                    int takeFirst = (int) 1e9, takeSecond = (int) 1e9;
                    if (i < first.length)
                        takeFirst = first[i] == '(' ? 1 + dp(i + 1, j, k + 1) : 1 + dp(i + 1, j, k - 1);
                    if (j < second.length)
                        takeSecond = second[j] == '(' ? 1 + dp(i, j + 1, k + 1) : 1 + dp(i, j + 1, k - 1);
                    return memo[i][j][k] = Math.min(takeFirst, takeSecond);
                }
            }
        }

        public static void trace(int i, int j, int k) {
            if (i == first.length && second.length == j) {
                while (k-- > 0)
                    s.append(')');
                return;
            }
            if (k == 0) {
                s.append('(');
                if (first.length > i && j < second.length && first[i] == '(' & second[j] == '(') {
                    trace(i + 1, j + 1, 1);
                    return;
                } else if (i < first.length && first[i] == '(') {
                    trace(i + 1, j, 1);
                    return;
                } else if (j < second.length && second[j] == '(')
                    trace(i, j + 1, 1);
                else
                    trace(i, j, 1);
            } else {
                int cur = dp(i, j, k);
                if (i < first.length && j < second.length && first[i] == second[j]) {
                    if (first[i] == '(') {
                        s.append('(');
                        trace(i + 1, j + 1, k + 1);
                        return;
                    } else {
                        s.append(')');
                        trace(i + 1, j + 1, k - 1);
                        return;
                    }
                } else {
                    int takeFirst = (int) 1e9, takeSecond = (int) 1e9;
                    if (i < first.length)
                        takeFirst = first[i] == '(' ? 1 + dp(i + 1, j, k + 1) : 1 + dp(i + 1, j, k - 1);
                    if (j < second.length)
                        takeSecond = second[j] == '(' ? 1 + dp(i, j + 1, k + 1) : 1 + dp(i, j + 1, k - 1);
                    if (cur == takeFirst) {
                        if (first[i] == '(') {
                            s.append('(');
                            trace(i + 1, j, k + 1);
                            return;
                        } else {
                            s.append(')');
                            trace(i + 1, j, k - 1);
                            return;
                        }
                    } else {
                        if (second[j] == '(') {
                            s.append('(');
                            trace(i, j + 1, k + 1);
                            return;
                        } else {
                            s.append(')');
                            trace(i, j + 1, k - 1);
                            return;
                        }
                    }
                }
            }
        }

        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            s = new StringBuilder();
            first = sc.next().toCharArray();
            second = sc.next().toCharArray();
            memo = new Integer[201][201][403];
            trace(0, 0, 0);
            pw.println(s.toString());
        }

    }

    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() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

    }
}

import java.io.*;
import java.util.*;

public class E {

	static char[] s1, s2;

	static int INF = (int) 1e9;

	static PrintWriter out = new PrintWriter(System.out);

	static int val(char c) {
		return c == '(' ? 1 : -1;
	}

	static int MAX = 420;

	static int[][][] memo;

	static int dp(int i, int j, int bal) {
		if (i == s1.length && j == s2.length)
			return bal;
		if (memo[i][j][bal] != -1)
			return memo[i][j][bal];
		int ans = INF;
		// open
		if (bal < MAX) {
			ans = Math.min(ans, 1 + dp(i + (i < s1.length && s1[i] == '(' ? 1 : 0),
					j + (j < s2.length && s2[j] == '(' ? 1 : 0), bal + 1));
		}

		boolean ad1 = i < s1.length && s1[i] == ')';
		boolean ad2 = j < s2.length && s2[j] == ')';
		if (bal > 0 && (ad1 || ad2))
			ans = Math.min(ans, 1 + dp(i + (ad1 ? 1 : 0), j + (ad2 ? 1 : 0), bal - 1));
		return memo[i][j][bal] = ans;

	}

	static void print(int i, int j, int bal) {
		if (i == s1.length && j == s2.length) {
			while (bal-- > 0)
				out.print(')');
			return;
		}

		int ans = dp(i, j, bal);
		// open
		if (bal < MAX && ans == 1 + dp(i + (i < s1.length && s1[i] == '(' ? 1 : 0),
				j + (j < s2.length && s2[j] == '(' ? 1 : 0), bal + 1)) {
			out.print('(');
			print(i + (i < s1.length && s1[i] == '(' ? 1 : 0), j + (j < s2.length && s2[j] == '(' ? 1 : 0), bal + 1);
			return;
		}
		out.print(')');
		boolean ad1 = i < s1.length && s1[i] == ')';
		boolean ad2 = j < s2.length && s2[j] == ')';
		print(i + (ad1 ? 1 : 0), j + (ad2 ? 1 : 0), bal - 1);

	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		s1 = sc.next().toCharArray();
		s2 = sc.next().toCharArray();
		memo = new int[201][201][MAX + 2];
		for (int[][] x2 : memo)
			for (int[] x : x2)
				Arrays.fill(x, -1);
		print(0, 0, 0);
		out.println();
		out.close();

	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		Scanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
		}

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

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

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

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

		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

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

	}

	static void sort(int[] a) {
		shuffle(a);
		Arrays.sort(a);
	}

	static void shuffle(int[] a) {
		int n = a.length;
		Random rand = new Random();
		for (int i = 0; i < n; i++) {
			int tmpIdx = rand.nextInt(n);
			int tmp = a[i];
			a[i] = a[tmpIdx];
			a[tmpIdx] = tmp;
		}
	}

}

/**
 * BaZ :D
 */

import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main
{
    static MyScanner scan;
    static PrintWriter pw;
    static long MOD = 1_000_000_007;
    static long INF = 1_000_000_000_000_000_000L;
    static long inf = 2_000_000_000;
    public static void main(String[] args) {
        new Thread(null, null, "BaZ", 1 << 27) {
            public void run() {
                try {
                    solve();
                } catch (Exception e) {
                    e.printStackTrace();
                    System.exit(1);
                }
            }
        }.start();
    }
    static int n,m,dp[][][],what[][][];
    static char a[], b[];
    static void solve() throws IOException
    {
        //initIo(true);
        initIo(false);
        StringBuilder sb = new StringBuilder();
        a = ne().toCharArray();
        b = ne().toCharArray();
        n = a.length;
        m = b.length;
        dp = new int[n+1][m+1][600];
        what = new int[n+1][m+1][600];
        for(int i=0;i<=n;++i) {
            for(int j=0;j<=m;++j) {
                Arrays.fill(dp[i][j], -1);
                Arrays.fill(what[i][j], -1);
            }
        }
        int min = f(0, 0, 0);
        int idx1 = 0, idx2 = 0, bal = 0;
        while(idx1 < n || idx2 < m) {
            if(what[idx1][idx2][bal] == 0) {
                sb.append("(");
                bal++;
                if(idx1<n && a[idx1] == '(') ++idx1;
                if(idx2<m && b[idx2] == '(') ++idx2;
            }
            else {
                sb.append(")");
                bal--;
                if(idx1<n && a[idx1] == ')') ++idx1;
                if(idx2<m && b[idx2] == ')') ++idx2;
            }
        }
        for(int i=0;i<bal;++i) {
            sb.append(")");
        }
        psb(sb);
        pw.flush();
        pw.close();
    }
    static int f(int idx1, int idx2, int bal) {
        if(bal>=600) {
            return 10000;
        }
        if(idx1 == n && idx2 == m) {
            return bal;
        }
        if(dp[idx1][idx2][bal] != -1) {
            return dp[idx1][idx2][bal];
        }
        int open_append = 1+f(idx1<n && a[idx1] == '(' ? idx1+1 : idx1, idx2<m && b[idx2] == '(' ? idx2+1 : idx2, bal+1);
        int close_append = Integer.MAX_VALUE;
        if(bal>0) {
            close_append = 1+f(idx1<n && a[idx1] == ')' ? idx1+1 : idx1, idx2<m && b[idx2] == ')' ? idx2+1 : idx2, bal-1);
        }
        if(open_append < close_append) {
            what[idx1][idx2][bal] = 0;
            return dp[idx1][idx2][bal] = open_append;
        }
        else {
            what[idx1][idx2][bal] = 1;
            return dp[idx1][idx2][bal] = close_append;
        }
    }
    static void initIo(boolean isFileIO) throws IOException {
        scan = new MyScanner(isFileIO);
        if(isFileIO) {
            pw = new PrintWriter("/Users/amandeep/Desktop/output.txt");
        }
        else {
            pw = new PrintWriter(System.out, true);
        }
    }
    static int ni() throws IOException
    {
        return scan.nextInt();
    }
    static long nl() throws IOException
    {
        return scan.nextLong();
    }
    static double nd() throws IOException
    {
        return scan.nextDouble();
    }
    static String ne() throws IOException
    {
        return scan.next();
    }
    static String nel() throws IOException
    {
        return scan.nextLine();
    }
    static void pl()
    {
        pw.println();
    }
    static void p(Object o)
    {
        pw.print(o+" ");
    }
    static void pl(Object o)
    {
        pw.println(o);
    }
    static void psb(StringBuilder sb)
    {
        pw.print(sb);
    }
    static void pa(String arrayName, Object arr[])
    {
        pl(arrayName+" : ");
        for(Object o : arr)
            p(o);
        pl();
    }
    static void pa(String arrayName, int arr[])
    {
        pl(arrayName+" : ");
        for(int o : arr)
            p(o);
        pl();
    }
    static void pa(String arrayName, long arr[])
    {
        pl(arrayName+" : ");
        for(long o : arr)
            p(o);
        pl();
    }
    static void pa(String arrayName, double arr[])
    {
        pl(arrayName+" : ");
        for(double o : arr)
            p(o);
        pl();
    }
    static void pa(String arrayName, char arr[])
    {
        pl(arrayName+" : ");
        for(char o : arr)
            p(o);
        pl();
    }
    static void pa(String listName, List list)
    {
        pl(listName+" : ");
        for(Object o : list)
            p(o);
        pl();
    }
    static void pa(String arrayName, Object[][] arr) {
        pl(arrayName+" : ");
        for(int i=0;i<arr.length;++i) {
            for(Object o : arr[i])
                p(o);
            pl();
        }
    }
    static void pa(String arrayName, int[][] arr) {
        pl(arrayName+" : ");
        for(int i=0;i<arr.length;++i) {
            for(int o : arr[i])
                p(o);
            pl();
        }
    }
    static void pa(String arrayName, long[][] arr) {
        pl(arrayName+" : ");
        for(int i=0;i<arr.length;++i) {
            for(long o : arr[i])
                p(o);
            pl();
        }
    }
    static void pa(String arrayName, char[][] arr) {
        pl(arrayName+" : ");
        for(int i=0;i<arr.length;++i) {
            for(char o : arr[i])
                p(o);
            pl();
        }
    }
    static void pa(String arrayName, double[][] arr) {
        pl(arrayName+" : ");
        for(int i=0;i<arr.length;++i) {
            for(double o : arr[i])
                p(o);
            pl();
        }
    }
    static class MyScanner
    {
        BufferedReader br;
        StringTokenizer st;
        MyScanner(boolean readingFromFile) throws IOException
        {
            if(readingFromFile) {
                br = new BufferedReader(new FileReader("/Users/amandeep/Desktop/input.txt"));
            }
            else {
                br = new BufferedReader(new InputStreamReader(System.in));
            }
        }
        String nextLine()throws IOException
        {
            return br.readLine();
        }
        String next() throws IOException
        {
            if(st==null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }
        int nextInt() throws IOException
        {
            return Integer.parseInt(next());
        }
        long nextLong() throws IOException
        {
            return Long.parseLong(next());
        }
        double nextDouble() throws IOException
        {
            return Double.parseDouble(next());
        }
    }
}

import java.util.*;
import java.io.*;
public class f {
	static int n, m, maxD = 202;
	static char[] a, b;
	static int[][][] dp;
	static char[][][] best;
	public static void main(String[] args) {
		FS sc = new FS();
		a = (sc.next() + "-").toCharArray();
		b = (sc.next() + "-").toCharArray();
		n = a.length;
		m = b.length;
		dp = new int[n][m][maxD + 1];
		for(int[][] z : dp) {
			for(int[] y : z) Arrays.fill(y, -1);
		}
		best = new char[n][m][maxD + 1];

		dp[n - 1][m - 1][0] = 0;
		best[n - 1][m - 1][0] = '\n';
		go(0, 0, 0);

		int ai = 0, bi = 0, d = 0;
		while(!(ai == n - 1 && bi == m - 1 && d == 0)) {
			char curr = best[ai][bi][d];
			System.out.print(curr);

			if(a[ai] == curr) ++ai;
			if(b[bi] == curr) ++bi;
			if(curr == '(') ++d;
			else --d;
		}
		System.out.println();
	}
	static int go(int ai, int bi, int d) {
		if(dp[ai][bi][d] != -1) return dp[ai][bi][d];

		int open = Integer.MAX_VALUE / 2;
		if(a[ai] == '(' || b[bi] == '(' || d == 0) {
			int aa = ai + (a[ai] == '(' ? 1 : 0);
			int bb = bi + (b[bi] == '(' ? 1 : 0);
			open = 1 + go(aa, bb, d + 1);
		}
		int close = Integer.MAX_VALUE / 2;
		if(d > 0) {
			int aa = ai + (a[ai] == ')' ? 1 : 0);
			int bb = bi + (b[bi] == ')' ? 1 : 0);
			close = 1 + go(aa, bb, d - 1);
		}

		if(open < close) best[ai][bi][d] = '(';
		else best[ai][bi][d] = ')';
		return dp[ai][bi][d] = Math.min(open, close);
	}
	static class FS {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		String next() {
			while(!st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch(Exception e) {}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
}

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class Code {
	static int[][][] dp = new int[250][250][500];
	static String[] bracket = new String[405];
	static char[]res = new char[500];
	public static int f(String s1,String s2,int a,int b,int c) {
		if(c>300)return dp[a][b][c] =c;
		if(a==s1.length()&&b==s2.length()) {
			//System.out.println(bracket[c]);
			return dp[a][b][c] = c;
		}
		if(dp[a][b][c]!=0)return dp[a][b][c];
		if(a<s1.length()&&b<s2.length()) {
			int t2=0;
			if(c>0) {
				t2 = 1 + (f(s1,s2,(s1.charAt(a)==')')?a+1:a,(s2.charAt(b)==')')?b+1:b,c-1));
			}
			int t1 = 1+(f(s1,s2,(s1.charAt(a)=='(')?a+1:a,(s2.charAt(b)=='(')?b+1:b,c+1));
			if(t2==0)t2= t1;
			if(t1<t2) {
				return dp[a][b][c] = t1;
			}
			else {

				return dp[a][b][c] = t2;
			}
		}else if(a<s1.length()&&b>=s2.length()) {
			int t2 = 0;
			if(c>0) {

				t2 = 1+(f(s1,s2,(s1.charAt(a)==')')?a+1:a,b,c-1));
			}
			int t1 =1+(f(s1,s2,(s1.charAt(a)=='(')?a+1:a,b,c+1));
			if(t2==0)
				t2=t1;

			if(t1<t2) {
				return dp[a][b][c] =t1;

			}
			else {
				return dp[a][b][c] =t2;
			}
		}else if(a>=s1.length()&&b<s2.length()) {
			int t2 = 0;
			if(c>0) {
				t2 =1+(f(s1,s2,a,(s2.charAt(b)==')')?b+1:b,c-1));
			}
			int t1 =1+(f(s1,s2,a,(s2.charAt(b)=='(')?b+1:b,c+1));
			if(t2==0)
				t2=t1;

			if(t1<t2) {
				return dp[a][b][c] =t1;
			}else {
				return dp[a][b][c] =t2;
			}
		}
		return dp[a][b][c] = 0;
	}
	public static void Tracedp(String s1,String s2,int a,int b,int c) {
		if(c>300)return ;
		if(a==s1.length()&&b==s2.length()) {
			System.out.println(bracket[c]);
			return;
		}
		if(a<s1.length()&&b<s2.length()) {
			int t2=0;
			if(c>0) {
				t2 = 1 + dp[(s1.charAt(a)==')')?a+1:a][(s2.charAt(b)==')')?b+1:b][c-1];
			}
			int t1 = 1 + dp[(s1.charAt(a)=='(')?a+1:a][(s2.charAt(b)=='(')?b+1:b][c+1];
			if(dp[a][b][c]==t1) {
				System.out.print("(");
				Tracedp(s1, s2, (s1.charAt(a)=='(')?a+1:a, (s2.charAt(b)=='(')?b+1:b, c+1);
			}
			else {
				System.out.print(")");
				Tracedp(s1, s2, (s1.charAt(a)==')')?a+1:a, (s2.charAt(b)==')')?b+1:b, c-1);
			}
		}else if(a<s1.length()&&b>=s2.length()) {
			int t2 = 0;
			if(c>0) {

				t2 = 1+dp[(s1.charAt(a)==')')?a+1:a][b][c-1];
			}
			int t1 =1+dp[(s1.charAt(a)=='(')?a+1:a][b][c+1];

			if(dp[a][b][c]==t1) {
				System.out.print("(");
				Tracedp(s1, s2, (s1.charAt(a)=='(')?a+1:a,b, c+1);
			}
			else {
				System.out.print(")");
				Tracedp(s1, s2, (s1.charAt(a)==')')?a+1:a, b, c-1);
			}
		}else if(a>=s1.length()&&b<s2.length()) {
			int t2 = 0;
			if(c>0) {
				t2 =1+dp[a][(s2.charAt(b)==')')?b+1:b][c-1];
			}
			int t1 =1+dp[a][(s2.charAt(b)=='(')?b+1:b][c+1];

			if(dp[a][b][c]==t1) {
				System.out.print("(");
				Tracedp(s1, s2, a, (s2.charAt(b)=='(')?b+1:b, c+1);
			}else {
				System.out.print(")");
				Tracedp(s1, s2, a, (s2.charAt(b)==')')?b+1:b, c-1);
			}
		}
	}
	public static void main(String[] args) throws IOException{
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		String s1 = sc.next();
		String s2 = sc.next();

		bracket[0] = "";
		for(int i=1;i<bracket.length;i++) {
			bracket[i] = bracket[i-1]+")";
		}
		int t =f(s1,s2,0,0,0);
		//System.out.println(t);
		Tracedp(s1, s2, 0, 0, 0);
		pw.flush();
		pw.close();
	}
}
class A1 implements Comparable<A1>{
	long a;long b;long value;
	public A1(long f,long g) {
		a = f;
		b = g;
		value = a*b;
	}
	@Override
	public int compareTo(A1 o) {
		// TODO Auto-generated method stub
		if(value>o.value)return 1;
		if(value<o.value)return -1;
		return 0;
	}
}
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();

    }
}

import java.io.*;
import java.util.*;

public class F
{
	static int oo = (int)1e3;

	public static long go(String a, String b, int i, int j, int open, long[][][] memo, String[][][] out)
	{
		if (memo[i][j][open] != -1)
			return memo[i][j][open];

		if (i == a.length() && j == b.length())
		{
			out[i][j][open] = "";

			for (int k = 0; k < open; k++)
				out[i][j][open] += ")";

			return memo[i][j][open] = open;
		}

		int il = i + ((i < a.length() && a.charAt(i) == '(') ? 1 : 0);
		int jl = j + ((j < b.length() && b.charAt(j) == '(') ? 1 : 0);
		long left = oo;

		if (((i < a.length() && a.charAt(i) == '(')) || (j < b.length() && b.charAt(j) == '(') || open == 0)
			left = 1 + go(a, b, il, jl, open + 1, memo, out);

		int ir = i + ((i < a.length() && a.charAt(i) == ')') ? 1 : 0);
		int jr = j + ((j < b.length() && b.charAt(j) == ')') ? 1 : 0);
		long right = oo;

		if (open > 0)
			right = 1 + go(a, b, ir, jr, open - 1, memo, out);

		if (left <= right)
			out[i][j][open] = "(" + out[il][jl][open + 1];
		else
			out[i][j][open] = ")" + out[ir][jr][open - 1];

		return memo[i][j][open] = Math.min(left, right);
	}

	public static void solve(FastIO io)
	{
		String a = io.next();
		String b = io.next();

		long[][][] memo = new long[a.length() + 1][b.length() + 1][405];
		String[][][] out = new String[a.length() + 1][b.length() + 1][405];

		for (long[][] i : memo)
			for (long[] j : i)
				Arrays.fill(j, -1);

		go(a, b, 0, 0, 0, memo, out);

		int i = 0, j = 0;
		int open = 0;

		// while (i != a.length() && j != b.length())
		// {
		// 	if (a.charAt(i) == b.charAt(j))
		// 	{
		// 		open += a.charAt(i) == '(' ? 1 : -1;
		// 	}
		// }
		io.println(out[0][0][0]);
	}

	public static void main(String[] args) {
		FastIO io = new FastIO();

		solve(io);

		io.close();
	}
}

class FastIO extends PrintWriter
{
	BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st = new StringTokenizer("");

	FastIO()
	{
		super(System.out);
	}

	public String next()
	{
		while (!st.hasMoreTokens())
		{
			try {
				st = new StringTokenizer(r.readLine());
			} catch (Exception e) {
				//TODO: handle exception
			}
		}
		return st.nextToken();
	}

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

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

	public double nextDouble()
	{
		return Double.parseDouble(next());
	}
}

//Created by Aminul on 12/12/2019.

import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class F {
    static int n, m, dp[][][];
    static char brackets[] = {'(', ')'}, a[], b[];

    public static void main(String[] args) throws Exception {
        new Thread(null ,new Runnable(){
            public void run(){
                try{solveIt();} catch(Exception e){e.printStackTrace(); System.exit(1);}
            }
        },"Main",1<<28).start();
    }

    public static void solveIt() throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        a = in.next().toCharArray();
        b = in.next().toCharArray();
        n = a.length;
        m = b.length;

        dp = new int[n + 1][m + 1][250];
        for (int a[][] : dp) for (int b[] : a) Arrays.fill(b, -1);

        int minLen = solve(0, 0, 0);
        StringBuilder result = new StringBuilder();
        getString(0, 0, 0, result);

        pw.println(result.toString());
        pw.close();
    }

    static int solve(int i, int j, int sum) {
        int res = (int) 1e8;
        if (sum >= 250) return res;
        if (i >= n && j >= m) {
            return sum;
        }
        if (dp[i][j][sum] != -1) return dp[i][j][sum];

        for (char bracket : brackets) {
            int newSum = sum + (bracket == '(' ? 1 : -1);
            if (newSum >= 0) {
                if (i < n && j < m && bracket == a[i] && bracket == b[j]) {
                    res = min(res, 1 + solve(i + 1, j + 1, newSum));
                } else if (i < n && bracket == a[i]) {
                    res = min(res, 1 + solve(i + 1, j, newSum));
                } else if (j < m && bracket == b[j]) {
                    res = min(res, 1 + solve(i, j + 1, newSum));
                } else {
                    res = min(res, 1 + solve(i, j, newSum));
                }
            }
        }
        return dp[i][j][sum] = res;
    }

    static void getString(int i, int j, int sum, StringBuilder sb) {
        if (sum >= 250) return;
        if (i >= n && j >= m) {
            while (sum > 0) {
                sb.append(")");
                sum--;
            }
            return;
        }
        int minVal = solve(i, j, sum);
        for (char bracket : brackets) {
            int newSum = sum + (bracket == '(' ? 1 : -1);
            if (newSum >= 0) {
                if (i < n && j < m && bracket == a[i] && bracket == b[j]) {
                    int res = 1 + solve(i + 1, j + 1, newSum);
                    if (res == minVal) {
                        sb.append(bracket);
                        getString(i + 1, j + 1, newSum, sb);
                        return;
                    }
                } else if (i < n && bracket == a[i]) {
                    int res = 1 + solve(i + 1, j, newSum);
                    if (res == minVal) {
                        sb.append(bracket);
                        getString(i + 1, j, newSum, sb);
                        return;
                    }
                } else if (j < m && bracket == b[j]) {
                    int res = 1 + solve(i, j + 1, newSum);
                    if (res == minVal) {
                        sb.append(bracket);
                        getString(i, j + 1, newSum, sb);
                        return;
                    }
                } else {
                    int res = 1 + solve(i, j, newSum);
                    if (res == minVal) {
                        sb.append(bracket);
                        getString(i, j, newSum, sb);
                        return;
                    }
                }
            }
        }
    }

    static void debug(Object... obj) {
        System.err.println(Arrays.deepToString(obj));
    }
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class P1272F
{
	static int oo = Integer.MAX_VALUE/2;
	static int[][][] dp;
	static char[] a, b;
	public static void main(String[] args)
	{
		FastScanner scan = new FastScanner();
		a = scan.next().toCharArray();
		b = scan.next().toCharArray();
		dp = new int[401][a.length+1][b.length+1];
		for (int[][] i : dp)
			for (int[] j : i)
				Arrays.fill(j, -1);
		int ans = go(0, 0, 0);
		StringBuilder sb = new StringBuilder();
		int ia = 0, ib = 0;
		int open = 0;
		for (int i = 0; i < ans; i++)
		{
			boolean aopen = ia < a.length ? a[ia] == '(' : false;
			boolean bopen = ib < b.length ? b[ib] == '(' : false;
			int anso = go(open+1, ia + (aopen ? 1 : 0), ib + (bopen ? 1 : 0));
			int ansc = go(open-1, ia + (aopen ? 0 : 1), ib + (bopen ? 0 : 1));
			if (anso <= ansc)
			{
				sb.append("(");
				open++;
				if (aopen)
					ia++;
				if (bopen)
					ib++;
			}
			else
			{
				sb.append(")");
				open--;
				if (!aopen)
					ia++;
				if (!bopen)
					ib++;
			}
		}
		System.out.println(sb);
	}
	private static int go(int open, int ia, int ib)
	{
		ia = Math.min(ia, a.length);
		ib = Math.min(ib, b.length);
		if (open < 0)
			return oo;
		if (ia >= a.length && ib >= b.length)
			return open;
		if (open >= dp.length)
			return oo;
		if (dp[open][ia][ib] >= 0)
			return dp[open][ia][ib];

		int ans = Integer.MAX_VALUE;
		boolean aopen = ia < a.length ? a[ia] == '(' : false;
		boolean bopen = ib < b.length ? b[ib] == '(' : false;
		// (
		ans = Math.min(ans, 1 + go(open+1, ia + (aopen ? 1 : 0), ib + (bopen ? 1 : 0)));
		// )
		ans = Math.min(ans, 1 + go(open-1, ia + (aopen ? 0 : 1), ib + (bopen ? 0 : 1)));
		return dp[open][ia][ib] = ans;
	}
	static class FastScanner
	{
		BufferedReader br;
		StringTokenizer st;

		public FastScanner()
		{
			try
			{
				br = new BufferedReader(new InputStreamReader(System.in));
				st = new StringTokenizer(br.readLine());
			} catch (Exception e)
			{
				e.printStackTrace();
			}
		}

		public String next()
		{
			if (st.hasMoreTokens())
				return st.nextToken();
			try
			{
				st = new StringTokenizer(br.readLine());
			} catch (Exception e)
			{
				e.printStackTrace();
			}
			return st.nextToken();
		}

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

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

		public String nextLine()
		{
			String line = "";
			try
			{
				line = br.readLine();
			} catch (Exception e)
			{
				e.printStackTrace();
			}
			return line;
		}
	}
}

import java.util.*;
import java.io.*;

public class R605F {

	public static void main(String[] args) {
		JS scan = new JS();
		PrintWriter out = new PrintWriter(System.out);
		String s = scan.next();
		String t = scan.next();
		int n = s.length();
		int m = t.length();

		int[][][] dp = new int[n+1][m+1][228];
		State[][][] prev = new State[n+1][m+1][228];
		for(int i = 0; i <= n; i++) {
			for(int j = 0; j <= m; j++) {
				Arrays.fill(dp[i][j], -1);
			}
		}

		ArrayDeque<State> q = new ArrayDeque<State>();
		dp[0][0][0] = 0;
		q.add(new State(0,0,0));
		while(!q.isEmpty()) {
			State p = q.poll();

			// place (
			int ni = p.a;
			int nj = p.b;
			if(p.a < n)
				if(s.charAt(p.a) == '(') ni++;
			if(p.b < m)
				if(t.charAt(p.b) == '(') nj++;
			if(p.c < 220 && dp[ni][nj][p.c+1] == -1) {
				dp[ni][nj][p.c+1] = dp[p.a][p.b][p.c]+1;
				prev[ni][nj][p.c+1] = p;
				q.add(new State(ni, nj, p.c+1));
			}

			// place )
			ni = p.a;
			nj = p.b;
			if(p.a < n)
				if(s.charAt(p.a) == ')') ni++;
			if(p.b < m)
				if(t.charAt(p.b) == ')') nj++;
			if(p.c > 0 && dp[ni][nj][p.c-1] == -1) {
				dp[ni][nj][p.c-1] = dp[p.a][p.b][p.c]+1;
				prev[ni][nj][p.c-1] = p;
				q.add(new State(ni, nj, p.c-1));
			}
		}

		State at = new State(n, m, 0);
		ArrayList<Character> lst = new ArrayList<Character>();
		while(at.a != 0 || at.b != 0 || at.c != 0) {
			State before = prev[at.a][at.b][at.c];
			if(before.c < at.c) {
				lst.add('(');
			}
			else {
				lst.add(')');
			}

			at = before;
		}

		for(int i = 0; i < lst.size(); i++) out.print(lst.get(lst.size()-i-1));
		out.println();
		out.flush();
//		System.out.println(lst);
//		System.out.println(dp[n][m][0]);
	}

	static class State{

		int a;
		int b;
		int c;

		public State(int a, int b, int c) {
			this.a = a;
			this.b = b;
			this.c = c;
		}
	}

	static class JS{
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public JS() {
			in = new BufferedInputStream(System.in, BS);
		}

		public JS(String s) throws FileNotFoundException {
			in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}
	}
}

//package round605;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class F {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		char[] s = ns().toCharArray();
		char[] t = ns().toCharArray();
		int n = s.length;
		int m = t.length;
		int w = 2*(n+m);
		int[][][] dp = new int[n+1][m+1][w+1];
		byte[][][] pre = new byte[n+1][m+1][w+1];
		for(int i = 0;i <= n;i++){
			for(int j = 0;j <= m;j++){
				Arrays.fill(dp[i][j], 99999999);
			}
		}
		dp[0][0][0] = 0;
		char[] oc = "()".toCharArray();
		for(int i = 0;i <= n;i++){
			for(int j = 0;j <= m;j++){
				for(int k = 0;k <= w;k++){
					for(char y : oc){
						int ni = i, nj = j, nk = k;
						if(i+1 <= n && s[i] == y)ni++;
						if(j+1 <= m && t[j] == y)nj++;
						nk += y == '(' ? 1 : -1;
						if(nk >= 0 && nk <= w && dp[ni][nj][nk] > dp[i][j][k] + 1){
							dp[ni][nj][nk] = dp[i][j][k] + 1;
							pre[ni][nj][nk] = (byte)(ni-i<<2|nj-j<<1|(y=='('?0:1));
						}
					}
				}
			}
		}

		int min = 99999999;
		int arg = 0;
		for(int k = 0;k <= w;k++){
			if(dp[n][m][k] + k < min){
				min = dp[n][m][k] + k;
				arg = k;
			}
		}

		int i = n, j = m, k = arg;
		char[] ret = new char[dp[n][m][k]];
		int q = ret.length-1;
		while(q >= 0){
			int p = pre[i][j][k];
			int ni = i-(p>>>2&1);
			int nj = j-(p>>>1&1);
			int nk = (p&1) == 0 ? k-1 : k+1;
			ret[q] = (p&1) == 0 ? '(' : ')';
			i = ni; j = nj; k = nk;
			q--;
		}
		out.print(new String(ret));
		for(int u = 0;u < arg;u++){
			out.print(")");
		}
		out.println();
	}

	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception { new F().run(); }

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }

	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }

	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}

	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}

	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	private void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Sparsh Sanchorawala
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        FTwoBracketSequences solver = new FTwoBracketSequences();
        solver.solve(1, in, out);
        out.close();
    }

    static class FTwoBracketSequences {
        char[] a;
        char[] b;
        int n;
        int m;
        int[][][] dp;
        Triple[][][] parent;

        void recur(int i, int j, int k) {
            dp[i][j][k] = (int) 1e5;
            int temp = (int) 1e5;
            int ni = i, nj = j;
            if (a[i] == '(')
                ni--;
            if (b[j] == '(')
                nj--;
            if (k - 1 >= 0) {
                if (dp[ni][nj][k - 1] == -1)
                    recur(ni, nj, k - 1);
                if (dp[ni][nj][k - 1] + 1 < temp) {
                    temp = dp[ni][nj][k - 1] + 1;
                    parent[i][j][k] = new Triple(ni, nj, k - 1);
                }
            }
            ni = i;
            nj = j;
            if (a[i] == ')')
                ni--;
            if (b[j] == ')')
                nj--;
            if (k + 1 <= (n + m)) {
                if (dp[ni][nj][k + 1] == -1)
                    recur(ni, nj, k + 1);
                if (dp[ni][nj][k + 1] + 1 < temp) {
                    temp = dp[ni][nj][k + 1] + 1;
                    parent[i][j][k] = new Triple(ni, nj, k + 1);
                }
            }
            dp[i][j][k] = temp;
        }

        public void solve(int testNumber, InputReader s, PrintWriter w) {
            a = (" " + s.next()).toCharArray();
            b = (" " + s.next()).toCharArray();
            n = a.length - 1;
            m = b.length - 1;
            dp = new int[n + 1][m + 1][(n + m) + 1];
            parent = new Triple[n + 1][m + 1][(n + m) + 1];
            for (int i = 0; i <= n; i++)
                for (int j = 0; j <= m; j++)
                    for (int k = 0; k <= (n + m); k++)
                        dp[i][j][k] = -1;
            dp[0][0][0] = 0;
            recur(n, m, 0);
            int i = n, j = m, k = 0;
            StringBuffer sb = new StringBuffer();
            while (parent[i][j][k] != null) {
                if (parent[i][j][k].k == k + 1)
                    sb.append(')');
                else
                    sb.append('(');
                int ni = parent[i][j][k].i;
                int nj = parent[i][j][k].j;
                int nk = parent[i][j][k].k;
                i = ni;
                j = nj;
                k = nk;
            }
            sb.reverse();
            w.println(sb.toString());
        }

        class Triple {
            int i;
            int j;
            int k;

            Triple(int i, int j, int k) {
                this.i = i;
                this.j = j;
                this.k = k;
            }

        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public String nextString() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                if (Character.isValidCodePoint(c)) {
                    res.appendCodePoint(c);
                }
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return nextString();
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}

import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {
	public static void main(String[] args) throws IOException {

//		for(int i=4;i<=4;i++) {
//			InputStream uinputStream = new FileInputStream("dining.in");
//			String f = i+".in";
//			InputStream uinputStream = new FileInputStream(f);
//			InputReader in = new InputReader(uinputStream);
//			PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("dining.out")));
			new Thread(null, new Task(),"haha",1<<26).start();
//		}
	}

	static class Task implements Runnable{
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		PrintWriter out = new PrintWriter(outputStream);
		InputReader in = new InputReader(inputStream);
		@Override
		public void run() {
			try {
				solve(in,out);
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		public void solve(InputReader in, PrintWriter out) throws IOException {
			char a[] = in.next().toCharArray();
			char b[] = in.next().toCharArray();
			int n = a.length;
			int m = b.length;
			int k = Math.max(n, m);
			int dp[][][] = new int[n+1][m+1][k+1];
			int pre[][][] = new int[n+1][m+1][k+1];
			int max = 999999999;
			for(int i=0;i<=n;i++) {
				for(int j=0;j<=m;j++) {
					for(int p=0;p<=k;p++) {
						if(i!=0||j!=0) dp[i][j][p] = max;
						else dp[i][j][p] = p;
					}
				}
			}
			for(int i=1;i<=n;i++) {
				if(a[i-1]=='(') {
					for(int p=1;p<=k;p++) {
						dp[i][0][p] = dp[i-1][0][p-1]+1;
						pre[i][0][p] = 1;
					}
				}else {
					for(int p=0;p<k;p++) {
						dp[i][0][p] = dp[i-1][0][p+1]+1;
						pre[i][0][p] = 1;
					}
				}
			}
			for(int j=1;j<=m;j++) {
				if(b[j-1]=='(') {
					for(int p=1;p<=k;p++) {
						dp[0][j][p] = dp[0][j-1][p-1]+1;
						pre[0][j][p] = 2;
					}
				}else {
					for(int p=0;p<k;p++) {
						dp[0][j][p] = dp[0][j-1][p+1]+1;
						pre[0][j][p] = 2;
					}
				}
			}
			for(int i=1;i<=n;i++) {
				for(int j=1;j<=m;j++) {
					if(a[i-1]==b[j-1]) {
						if(a[i-1]=='(') {
							for(int p=1;p<=k;p++) {
								if(dp[i-1][j-1][p-1]+1<dp[i][j][p]) {
									dp[i][j][p] = dp[i-1][j-1][p-1]+1;
									pre[i][j][p] = 3;
								}
								if(p>=2&&dp[i-1][j-1][p-2]+2<dp[i][j][p]) {
									dp[i][j][p] = dp[i-1][j-1][p-2]+2;
									pre[i][j][p] = 4;
								}
							}
						}else {
							for(int p=0;p<k;p++) {
								if(dp[i-1][j-1][p+1]+1<dp[i][j][p]) {
									dp[i][j][p] = dp[i-1][j-1][p+1]+1;
									pre[i][j][p] = 3;
								}
								if(p<k-1&&dp[i-1][j-1][p+2]+2<dp[i][j][p]) {
									dp[i][j][p] = dp[i-1][j-1][p+2]+2;
									pre[i][j][p] = 4;
								}
							}
						}
					}else {
						if(a[i-1]=='(') {
							for(int p=0;p<=k;p++) {
								int aa = p>0?dp[i-1][j][p-1]+1:max;
								int bb = p<k?dp[i][j-1][p+1]+1:max;
								if(aa<dp[i][j][p]) {
									dp[i][j][p] = aa;
									pre[i][j][p] = 1;
								}
								if(bb<dp[i][j][p]) {
									dp[i][j][p] = bb;
									pre[i][j][p] = 2;
								}
							}
						}else {
							for(int p=0;p<=k;p++) {
								int aa = p<k?dp[i-1][j][p+1]+1:max;
								int bb = p>0?dp[i][j-1][p-1]+1:max;
								if(aa<dp[i][j][p]) {
									dp[i][j][p] = aa;
									pre[i][j][p] = 1;
								}
								if(bb<dp[i][j][p]) {
									dp[i][j][p] = bb;
									pre[i][j][p] = 2;
								}
							}
						}
					}
				}
			}
			int ret = max;
			int ret_idx = -1;
			for(int i=0;i<=k;i++) {
				if(dp[n][m][i]+i<ret) {
					ret=dp[n][m][i]+i;
					ret_idx = i;
				}
			}
			//out.println(ret);
			print(pre,n,m,ret_idx,a,b,out);
			for(int p=0;p<ret_idx;p++) out.print(')');
		}
		void print(int pre[][][], int i, int j, int l, char[] a, char[] b, PrintWriter out) {
			if(i==0&&j==0) {
				for(int p=0;p<l;p++) out.print('(');
				return;
			}
			if(pre[i][j][l]==4) {
				if(a[i-1]=='(') {
					print(pre,i-1,j-1,l-2,a,b,out);
				}else {
					print(pre,i-1,j-1,l+2,a,b,out);
				}
				out.print(a[i-1]);
				out.print(a[i-1]);
			}
			else if(pre[i][j][l]==3) {
				if(a[i-1]=='(') {
					print(pre,i-1,j-1,l-1,a,b,out);
				}else {
					print(pre,i-1,j-1,l+1,a,b,out);
				}
				out.print(a[i-1]);
			}else if(pre[i][j][l]==2) {
				if(b[j-1]=='(') {
					print(pre,i,j-1,l-1,a,b,out);
				}else {
					print(pre,i,j-1,l+1,a,b,out);
				}
				out.print(b[j-1]);
			}else {
				if(a[i-1]=='(') {
					print(pre,i-1,j,l-1,a,b,out);
				}else {
					print(pre,i-1,j,l+1,a,b,out);
				}
				out.print(a[i-1]);
			}
		}
		class edge {
			int f,t,len;
			public edge(int a, int b, int c) {
				f=a;t=b;len=c;
			}
		}

		class pair implements Comparable<pair>{
			int idx, val;
			public pair(int a, int b) {
				idx = a;
				val = b;
			}
			@Override
			public int compareTo(pair t) {
				return this.val-t.val;
			}
		}

	    class sgt{
	    	sgt lt;
	    	sgt rt;
	    	int l,r;
	    	long sum, max, min, lazy;
	    	public sgt(int L, int R, int arr[]) {
	    		l=L;r=R;
	    		if(l==r-1) {
	    			sum = max = min = arr[l];
	    			lazy = 0;
	    			return;
	    		}
	    		lt = new sgt(l, l+r>>1, arr);
	    		rt = new sgt(l+r>>1, r, arr);
	    		pop_up();
	    	}
	    	void pop_up() {
	    		this.sum = lt.sum + rt.sum;
	    		this.max = Math.max(lt.max, rt.max);
	    		this.min = Math.min(lt.min, rt.min);
	    	}
	    	void push_down() {
	    		if(this.lazy!=0) {
	    			lt.sum+=lazy;
	    			rt.sum+=lazy;
	    			lt.max+=lazy;
	    			lt.min+=lazy;
	    			rt.max+=lazy;
	    			rt.min+=lazy;
	    			lt.lazy+=this.lazy;
	    			rt.lazy+=this.lazy;
	    			this.lazy = 0;
	    		}
	    	}
	    	void change(int L, int R, int v) {
	    		if(R<=l||r<=L) return;
	    		if(L<=l&&r<=R) {
	    			this.max+=v;
	    			this.min+=v;
	    			this.sum+=v*(r-l);
	    			this.lazy+=v;
	    			return;
	    		}
	    		push_down();
	    		lt.change(L, R, v);
	    		rt.change(L, R, v);
	    		pop_up();
	    	}
	    	long query_max(int L, int R) {
	    		if(L<=l&&r<=R) return this.max;
	    		if(r<=L||R<=l) return Long.MIN_VALUE;
	    		push_down();
	    		return Math.max(lt.query_max(L, R), rt.query_max(L, R));
	    	}
	    	long query_min(int L, int R) {
	    		if(L<=l&&r<=R) return this.min;
	    		if(r<=L||R<=l) return Long.MAX_VALUE;
	    		push_down();
	    		return Math.min(lt.query_min(L, R), rt.query_min(L, R));
	    	}
	    	long query_sum(int L, int R) {
	    		if(L<=l&&r<=R) return this.sum;
	    		if(r<=L||R<=l) return 0;
	    		push_down();
	    		return lt.query_sum(L, R) + rt.query_sum(L, R);
	    	}
	    }

		List<List<String>> convert(String arr[][]){
			int n = arr.length;
			List<List<String>> ret = new ArrayList<>();
			for(int i=0;i<n;i++) {
				ArrayList<String> tmp = new ArrayList<String>();
				for(int j=0;j<arr[i].length;j++) tmp.add(arr[i][j]);
				ret.add(tmp);
			}
			return ret;
		}

		public class TreeNode {
			int val;
			TreeNode left;
			TreeNode right;
			TreeNode(int x) { val = x; }
		}

		public int GCD(int a, int b) {
		   if (b==0) return a;
		   return GCD(b,a%b);
		}
		public long GCD(long a, long b) {
			   if (b==0) return a;
			   return GCD(b,a%b);
		}
	}

    static class ArrayUtils {
        static final long seed = System.nanoTime();
        static final Random rand = new Random(seed);

        public static void sort(int[] a) {
            shuffle(a);
            Arrays.sort(a);
        }

        public static void shuffle(int[] a) {
            for (int i = 0; i < a.length; i++) {
                int j = rand.nextInt(i + 1);
                int t = a[i];
                a[i] = a[j];
                a[j] = t;
            }
        }

    }
	static class BIT{
		int arr[];
		int n;
		public BIT(int a) {
			n=a;
			arr = new int[n];
		}
		int sum(int p) {
			int s=0;
			while(p>0) {
				s+=arr[p];
				p-=p&(-p);
			}
			return s;
		}
		void add(int p, int v) {
			while(p<n) {
				arr[p]+=v;
				p+=p&(-p);
			}
		}
	}
	static class DSU{
		int[] arr;
		int[] sz;
		public DSU(int n) {
			arr = new int[n];
			sz = new int[n];
			for(int i=0;i<n;i++) arr[i] = i;
			Arrays.fill(sz, 1);
		}
		public int find(int a) {
			if(arr[a]!=a) arr[a] = find(arr[a]);
			return arr[a];
		}
		public void union(int a, int b) {
			int x = find(a);
			int y = find(b);
			if(x==y) return;
			arr[y] = x;
			sz[x] += sz[y];
		}
		public int size(int x) {
			return sz[find(x)];
		}
	}
	static class MinHeap<Key> implements Iterable<Key> {
		private int maxN;
		private int n;
		private int[] pq;
		private int[] qp;
		private Key[] keys;
		private Comparator<Key> comparator;

		public MinHeap(int capacity){
			if (capacity < 0) throw new IllegalArgumentException();
			this.maxN = capacity;
			n=0;
			pq = new int[maxN+1];
			qp = new int[maxN+1];
			keys = (Key[]) new Object[capacity+1];
			Arrays.fill(qp, -1);
		}

		public MinHeap(int capacity, Comparator<Key> c){
			if (capacity < 0) throw new IllegalArgumentException();
			this.maxN = capacity;
			n=0;
			pq = new int[maxN+1];
			qp = new int[maxN+1];
			keys = (Key[]) new Object[capacity+1];
			Arrays.fill(qp, -1);
			comparator = c;
		}
		public boolean isEmpty()	{ return n==0; 	}
		public int size()			{ return n;		}
		public boolean contains(int i) {
	        if (i < 0 || i >= maxN) throw new IllegalArgumentException();
	        return qp[i] != -1;
		}
		public int peekIdx() {
	        if (n == 0) throw new NoSuchElementException("Priority queue underflow");
	        return pq[1];
		}
		public Key peek(){
			if(isEmpty()) throw new NoSuchElementException("Priority queue underflow");
			return keys[pq[1]];
		}
		public int poll(){
			if(isEmpty()) throw new NoSuchElementException("Priority queue underflow");
			int min = pq[1];
			exch(1,n--);
			down(1);
			assert min==pq[n+1];
			qp[min] = -1;
			keys[min] = null;
			pq[n+1] = -1;
			return min;
		}
	    public void update(int i, Key key) {
	        if (i < 0 || i >= maxN) throw new IllegalArgumentException();
	        if (!contains(i)) {
	        	this.add(i, key);
	        }else {
	        	keys[i] = key;
	        	up(qp[i]);
	        	down(qp[i]);
	        }
	    }
		private void add(int i, Key x){
	        if (i < 0 || i >= maxN) throw new IllegalArgumentException();
	        if (contains(i)) throw new IllegalArgumentException("index is already in the priority queue");
	        n++;
	        qp[i] = n;
	        pq[n] = i;
	        keys[i] = x;
	        up(n);
		}
		private void up(int k){
			while(k>1&&less(k,k/2)){
				exch(k,k/2);
				k/=2;
			}
		}
		private void down(int k){
			while(2*k<=n){
				int j=2*k;
				if(j<n&&less(j+1,j)) j++;
				if(less(k,j)) break;
				exch(k,j);
				k=j;
			}
		}

		public boolean less(int i, int j){
	        if (comparator == null) {
	            return ((Comparable<Key>) keys[pq[i]]).compareTo(keys[pq[j]]) < 0;
	        }
	        else {
	            return comparator.compare(keys[pq[i]], keys[pq[j]]) < 0;
	        }
		}

		public void exch(int i, int j){
	        int swap = pq[i];
	        pq[i] = pq[j];
	        pq[j] = swap;
	        qp[pq[i]] = i;
	        qp[pq[j]] = j;
		}

		@Override
		public Iterator<Key> iterator() {
			// TODO Auto-generated method stub
			return null;
		}
	}

    private static class InputReader
    {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int zcurChar;
        private int znumChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream)
        {
            this.stream = stream;
        }

        public int read()
        {
            if (znumChars == -1)
                throw new InputMismatchException();
            if (zcurChar >= znumChars)
            {
            	zcurChar = 0;
                try
                {
                    znumChars = stream.read(buf);
                } catch (IOException e)
                {
                    throw new InputMismatchException();
                }
                if (znumChars <= 0)
                    return -1;
            }
            return buf[zcurChar++];
        }

        public int nextInt()
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-')
            {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do
            {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public String nextString()
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do
            {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public double nextDouble()
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-')
            {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.')
            {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.')
            {
                c = read();
                double m = 1;
                while (!isSpaceChar(c))
                {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

        public long nextLong()
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-')
            {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do
            {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c)
        {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next()
        {
            return nextString();
        }

        public interface SpaceCharFilter
        {
            public boolean isSpaceChar(int ch);
        }
        public int[] readIntArray(int n) {
            int[] ret = new int[n];
            for (int i = 0; i < n; i++) {
                ret[i] = nextInt();
            }
            return ret;
        }
    }

	static class Dumper {
		static void print_int_arr(int[] arr) {
			for (int i = 0; i < arr.length; i++) {
				System.out.print(arr[i] + " ");
			}
			System.out.println();
			System.out.println("---------------------");
		}

		static void print_char_arr(char[] arr) {
			for (int i = 0; i < arr.length; i++) {
				System.out.print(arr[i] + " ");
			}
			System.out.println();
			System.out.println("---------------------");
		}

		static void print_double_arr(double[] arr) {
			for (int i = 0; i < arr.length; i++) {
				System.out.print(arr[i] + " ");
			}
			System.out.println();
			System.out.println("---------------------");
		}

		static void print_2d_arr(int[][] arr, int x, int y) {
			for (int i = 0; i < x; i++) {
				for (int j = 0; j < y; j++) {
					System.out.print(arr[i][j] + " ");
				}
				System.out.println();
			}
			System.out.println();
			System.out.println("---------------------");
		}

		static void print_2d_arr(boolean[][] arr, int x, int y) {
			for (int i = 0; i < x; i++) {
				for (int j = 0; j < y; j++) {
					System.out.print(arr[i][j] + " ");
				}
				System.out.println();
			}
			System.out.println();
			System.out.println("---------------------");
		}

		static void print(Object o) {
			System.out.println(o.toString());
		}

		static void getc() {
			System.out.println("here");
		}
	}
}

import java.io.*;
import java.util.*;

public class Problem_F {
	static final int INF = Integer.MAX_VALUE / 2;
	static char[] S, T;
	static int[][][] dp, dp2;

	public static void solve(int t, int i, int j, int k) {
		int x, y;
		x = i - 1 + t % 2;
		y = j - (t + 1) / 2;
		if ((t % 2 == 0 ? S[i] : T[j]) == '(') {
			if (k > 0 && dp[i][j][k] > dp[x][y][k - 1] + 1) {
				dp[i][j][k] = dp[x][y][k - 1] + 1;
				dp2[i][j][k] = t;
			}
		} else {
			if (k < 200 && dp[i][j][k] > dp[x][y][k + 1] + 1) {
				dp[i][j][k] = dp[x][y][k + 1] + 1;
				dp2[i][j][k] = t;
			}
		}
	}

	public static void main(String[] args) {
		InputReader in = new InputReader();
		StringBuilder out = new StringBuilder();

		S = (" " + in.nextLine()).toCharArray();
		T = (" " + in.nextLine()).toCharArray();
		dp = new int[S.length][T.length][201];
		dp2 = new int[S.length][T.length][201];
		for (int i = 0; i < S.length; i++) {
			for (int j = 0; j < T.length; j++) {
				Arrays.fill(dp[i][j], INF);
			}
		}
		for (int i = 0; i < 201; i++) {
			dp[0][0][i] = i;
		}
		for (int i = 0; i < S.length; i++) {
			for (int j = i == 0 ? 1 : 0; j < T.length; j++) {
				for (int k = 0; k < 201; k++) {
					if (i > 0) {
						solve(0, i, j, k);
					}
					if (j > 0) {
						solve(1, i, j, k);
					}
					if (i > 0 && j > 0 && S[i] == T[j]) {
						solve(2, i, j, k);
					}
				}
			}
		}
		int k = 0;
		for (int i = 0; i < 201; i++) {
			if (dp[S.length - 1][T.length - 1][k] + k > dp[S.length - 1][T.length - 1][i] + i) {
				k = i;
			}
		}
		for (int i = 0; i < k; i++) {
			out.append(')');
		}
		int x = S.length - 1;
		int y = T.length - 1;
		while (x > 0 || y > 0) {
			if (dp2[x][y][k] == 0) {
				out.append(S[x]);
				k += S[x] == ')' ? 1 : -1;
				x--;
			} else if (dp2[x][y][k] == 1) {
				out.append(T[y]);
				k += T[y] == ')' ? 1 : -1;
				y--;
			} else {
				out.append(S[x]);
				k += S[x] == ')' ? 1 : -1;
				x--;
				y--;
			}
		}
		while (k-- > 0) {
			out.append('(');
		}
		out.reverse().append('\n');

		System.out.print(out);
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer st;

		public InputReader() {
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

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

		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}

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

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author NMouad21
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    FTwoBracketSequences solver = new FTwoBracketSequences();
    solver.solve(1, in, out);
    out.close();
  }

  static class FTwoBracketSequences {

    private int n;
    private int m;
    private int mx;
    private char[] s;
    private char[] t;
    private int[][][] dp;
    private char[][][] decision;

    private final int solve(int i, int j, int d) {
      if (d < 0 || d >= mx) {
        return Constants.INF32;
      }
      if (i == n && j == m) {
        for (int x = d; x > 0; x--) {
          decision[i][j][x] = ')';
        }
        return d;
      }
      if (dp[i][j][d] != -1) {
        return dp[i][j][d];
      }

      int ans = Constants.INF32;
      for (char c : "()".toCharArray()) {
        int nans =
            solve(i + (s[i] == c ? 1 : 0), j + (t[j] == c ? 1 : 0), d + (c == '(' ? 1 : -1)) + 1;
        if (nans < ans) {
          ans = nans;
          decision[i][j][d] = c;
        }
      }

      return dp[i][j][d] = ans;
    }

    public final void solve(int testNumber, InputReader in, PrintWriter out) {
      s = (in.next() + "#").toCharArray();
      n = s.length - 1;
      t = (in.next() + "#").toCharArray();
      m = t.length - 1;
      mx = (Math.max(n, m) + 1) << 1;
      dp = new int[n + 1][m + 1][mx];
      decision = new char[n + 1][m + 1][mx];
      ArrayUtils.deepFill(dp, -1);
      solve(0, 0, 0);

      int i = 0, j = 0, d = 0;
      while (decision[i][j][d] != 0) {
        out.print(decision[i][j][d]);
        int ni = i + (s[i] == decision[i][j][d] ? 1 : 0);
        int nj = j + (t[j] == decision[i][j][d] ? 1 : 0);
        int nd = d + ('(' == decision[i][j][d] ? 1 : -1);
        i = ni;
        j = nj;
        d = nd;
      }
      out.println();
    }

  }

  static final class InputReader {

    private final InputStream stream;
    private final byte[] buf = new byte[1 << 16];
    private int curChar;
    private int numChars;

    public InputReader() {
      this.stream = System.in;
    }

    public InputReader(final InputStream stream) {
      this.stream = stream;
    }

    private final int read() {
      if (this.numChars == -1) {
        throw new UnknownError();
      } else {
        if (this.curChar >= this.numChars) {
          this.curChar = 0;

          try {
            this.numChars = this.stream.read(this.buf);
          } catch (IOException ex) {
            throw new InputMismatchException();
          }

          if (this.numChars <= 0) {
            return -1;
          }
        }

        return this.buf[this.curChar++];
      }
    }

    public final String next() {
      int c;
      while (isSpaceChar(c = this.read())) {
      }

      StringBuilder result = new StringBuilder();
      result.appendCodePoint(c);

      while (!isSpaceChar(c = this.read())) {
        result.appendCodePoint(c);
      }

      return result.toString();
    }

    private static final boolean isSpaceChar(final int c) {
      return c == 32 || c == 10 || c == 13 || c == 9
          || c == -1; // 32 == ' ', 10 == '\n', 13 == '\r', 9 == '\t'
    }

  }

  static final class ArrayUtils {

    private ArrayUtils() {
      throw new RuntimeException("DON'T");
    }

    public static final void deepFill(Object o, int v) {
      if (!o.getClass().isArray()) {
        throw new IllegalArgumentException();
      }
      if (o instanceof int[]) {
        int[] arr = (int[]) o;
        Arrays.fill(arr, v);
      } else if (o instanceof Integer[]) {
        Integer[] arr = (Integer[]) o;
        Arrays.fill(arr, v);
      } else {
        Object[] objArray = (Object[]) o;
        for (Object obj : objArray) {
          deepFill(obj, v);
        }
      }
    }

  }

  static class Constants {

    public static final int INF32 = 0x3f3f3f3f;

  }
}

/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class x1272F
   {
      static int[][][] dp;
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         String input1 = infile.readLine();
         String input2 = infile.readLine();
         char[] a = input1.toCharArray();
         char[] b = input2.toCharArray();
         int N = a.length;
         int M = b.length;
         dp = new int[N+M+5][N+1][M+1];
         //I have a brain tumor
         //bal, # of processed chars for each string
         Node[][][] parent = new Node[N+M+5][N+1][M+1];
         for(int i=0; i <= N+M; i++)
            for(int a1=0; a1 <= N; a1++)
               for(int b1=0; b1 <= M; b1++)
                  dp[i][a1][b1] = 6969;
         dp[0][0][0] = 0;
         for(int i=0; i <= N; i++)
            for(int j=0; j <= M; j++)
               for(int bal=0; bal <= N+M; bal++)
                  if(dp[bal][i][j] != 6969)
                  {
                     int x = N;
                     if(i < N)
                        x = i+Math.max(0, val(a[i]));
                     int y = M;
                     if(j < M)
                        y = j+Math.max(0, val(b[j]));
                     if(dp[bal+1][x][y] > dp[bal][i][j]+1)
                     {
                        dp[bal+1][x][y] = dp[bal][i][j]+1;
                        parent[bal+1][x][y] = new Node(bal,i,j);
                     }
                     x = N;
                     if(i < N)
                        x = i+Math.max(0, -1*val(a[i]));
                     y = M;
                     if(j < M)
                        y = j+Math.max(0, -1*val(b[j]));
                     if(bal > 0 && dp[bal-1][x][y] > dp[bal][i][j]+1)
                     {
                        dp[bal-1][x][y] = dp[bal][i][j]+1;
                        parent[bal-1][x][y] = new Node(bal,i,j);
                     }
                  }
         int curr = 0;
         for(int i=1; i <= N+M; i++)
            if(dp[i][N][M]+i < dp[curr][N][M]+curr)
               curr = i;
         int d = curr;
         int e = N;
         int f = M;
         StringBuilder sb = new StringBuilder();
         for(int i=0; i < curr; i++)
            sb.append(")");
         while(parent[d][e][f] != null)
         {
            Node par = parent[d][e][f];
            if(par.bal < d)
               sb.append("(");
            else
               sb.append(")");
            d = par.bal;
            e = par.x;
            f = par.y;
         }
         //System.out.println(dp[curr][N][M]+curr);
         System.out.println(sb.reverse());
      }
      public static int val(char c)
      {
         if(c == '(')
            return 1;
         return -1;
      }
   }
   class Node
   {
      public int bal;
      public int x;
      public int y;

      public Node(int a, int b, int c)
      {
         bal = a;
         x = b;
         y = c;
      }
   }

import java.io.*;
import java.util.*;

public class D {

    public static void main(String[] args) {
        FastReader scan = new FastReader();
        PrintWriter out = new PrintWriter(System.out);
        Task solver = new Task();
        int t = 1;
        while (t --> 0) solver.solve(1, scan, out);
        out.close();
    }

    static class Task {
        static char[] a, b;
        static ArrayDeque<State> queue = new ArrayDeque<>();
        static boolean[][][] found;
        static State ans = null;

        public void solve(int testNumber, FastReader scan, PrintWriter out) {
            a = scan.next().toCharArray();
            b = scan.next().toCharArray();
            queue.addLast(new State(0, 0, 0, 'N'));
            found = new boolean[a.length+1][b.length+1][a.length+b.length+1];
            while(!queue.isEmpty()) {
                State p = queue.pollFirst();
                if(p.x == a.length && p.y == b.length && p.z == 0) {
                    ans = p;
                    break;
                }
                if(p.z < found[0][0].length-1) {
                    State open = next(p, '(');
                    if (!found[open.x][open.y][open.z]) {
                        queue.addLast(open);
                        found[open.x][open.y][open.z] = true;
                    }
                }
                if(p.z > 0) {
                    State closed = next(p, ')');
                    if (!found[closed.x][closed.y][closed.z]) {
                        queue.addLast(closed);
                        found[closed.x][closed.y][closed.z] = true;
                    }
                }
            }
            StringBuilder res = new StringBuilder();
            while(ans.prev != null) {
                res.append(ans.curr);
                ans = ans.prev;
            }
            out.println(res.reverse());
        }

        static State next(State prev, char curr) {
            State ret = new State(prev.x, prev.y, prev.z, curr);
            if(ret.x != a.length && a[ret.x] == curr) ret.x++;
            if(ret.y != b.length && b[ret.y] == curr) ret.y++;
            ret.z += curr == '(' ? 1 : -1;
            ret.prev = prev;
            return ret;
        }

        static class State {
            int x, y, z;
            State prev = null;
            char curr;
            public State(int a, int b, int c, char d) {
                x = a;
                y = b;
                z = c;
                curr = d;
            }
        }

    }

    static void shuffle(int[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            int temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }

    static void shuffle(long[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            long temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws FileNotFoundException {
            br = new BufferedReader(new FileReader(new File(s)));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

// javac f.java && java _

import java.io.*;
import java.util.*;

public class f {
	public static void main(String[] args) { new f(); }
	FS in = new FS();
	PrintWriter out = new PrintWriter(System.out);

	int sn, tn, n;
	int oo = 1 << 16;
	char[] s, t;
	int[][][] dp;

	f() {
		s = in.next().toCharArray();
		t = in.next().toCharArray();

		sn = s.length;
		tn = t.length;
		n = sn + tn;

		dp = new int[sn + 1][tn + 1][n];
		for (int i = 0; i <= sn; i++)
			for (int j = 0; j <= tn; j++)
				Arrays.fill(dp[i][j], -1);

		int min = dp(0, 0, 0);
		buildback(0, 0, 0, min);
		out.close();
	}

	void buildback(int l, int r, int x, int seek) {
		if (l == sn && r == tn && x == 0) {
			out.println();
			return;
		}
		if (l == sn && r == tn) {
			out.print(")");
			buildback(l, r, x - 1, seek - 1);
			return;
		}

		if (l < sn && r < tn) {
			int lx = s[l] == '(' ? 1 : -1;
			int rx = t[r] == '(' ? 1 : -1;

			if (lx == rx && x + lx >= 0) {
				if (dp[l + 1][r + 1][x + lx] == seek - 1) {
					out.print(s[l]);
					buildback(l + 1, r + 1, x + lx, seek - 1);
					return;
				}
			}
			else if (lx == rx) {
				if (dp[l][r][x + 1] == seek - 1)  {
					out.print("(");
					buildback(l, r, x + 1, seek - 1);
					return;
				}
			}

			if (x + lx >= 0) {
				if (dp[l + 1][r][x + lx] == seek - 1) {
					out.print(s[l]);
					buildback(l + 1, r, x + lx, seek - 1);
					return;
				}
			}
			else if (dp[l][r][x + 1] == seek - 1) {
				out.print("(");
				buildback(l, r, x + 1, seek - 1);
				return;
			}

			if (x + rx >= 0) {
				if (dp[l][r + 1][x + rx] == seek - 1) {
					out.print(t[r]);
					buildback(l, r + 1, x + rx, seek - 1);
					return;
				}
			}
			else if (dp[l][r][x + 1] == seek - 1) {
				out.print("(");
				buildback(l, r, x + 1, seek - 1);
				return;
			}
		}
		else if (l < sn) {
			int lx = s[l] == '(' ? 1 : -1;
			if (x + lx >= 0) {
				if (dp[l + 1][r][x + lx] == seek - 1) {
					out.print(s[l]);
					buildback(l + 1, r, x + lx, seek - 1);
					return;
				}
			}
			else if (dp[l][r][x + 1] == seek - 1) {
				out.print("(");
				buildback(l, r, x + 1, seek - 1);
				return;
			}
		}
		else if (r < tn) {
			int rx = t[r] == '(' ? 1 : -1;
			if (x + rx >= 0) {
				if (dp[l][r + 1][x + rx] == seek - 1) {
					out.print(t[r]);
					buildback(l, r + 1, x + rx, seek - 1);
					return;
				}
			}
			else if (dp[l][r][x + 1] == seek - 1) {
				out.print("(");
				buildback(l, r, x + 1, seek - 1);
				return;
			}
		}
	}

	int dp(int l, int r, int x) {
		if (x >= n) return oo;
		if (l == sn && r == tn && x == 0) return dp[l][r][x] = 0;
		if (l == sn && r == tn) return dp[l][r][x] =1 + dp(l, r, x - 1);
		if (dp[l][r][x] != -1) return dp[l][r][x];

		int ans = oo;
		if (l < sn && r < tn) {
			int lx = s[l] == '(' ? 1 : -1;
			int rx = t[r] == '(' ? 1 : -1;

			if (lx == rx && x + lx >= 0) ans = min(ans, 1 + dp(l + 1, r + 1, x + lx));
			else if (lx == rx) ans = min(ans, 1 + dp(l, r, x + 1));

			if (x + lx >= 0) ans = min(ans, 1 + dp(l + 1, r, x + lx));
			else ans = min(ans, 1 + dp(l, r, x + 1));

			if (x + rx >= 0) ans = min(ans, 1 + dp(l, r + 1, x + rx));
			else ans = min(ans, 1 + dp(l, r, x + 1));
		}
		else if (l < sn) {
			int lx = s[l] == '(' ? 1 : -1;

			if (x + lx >= 0) ans = min(ans, 1 + dp(l + 1, r, x + lx));
			else ans = min(ans, 1 + dp(l, r, x + 1));
		}
		else if (r < tn) {
			int rx = t[r] == '(' ? 1 : -1;

			if (x + rx >= 0) ans = min(ans, 1 + dp(l, r + 1, x + rx));
			else ans = min(ans, 1 + dp(l, r, x + 1));
		}

		return dp[l][r][x] = ans;
	}

	int min(int a, int b) { if (a < b) return a; return b; }
	int max(int a, int b) { if (a > b) return a; return b; }
	long min(long a, long b) { if (a < b) return a; return b; }
	long max(long a, long b) { if (a > b) return a; return b; }

	boolean z(int x) { if (x == 0) return true; return false; }
	boolean z(long x) { if (x == 0) return true; return false; }

	class FS {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens()) {
				try { st = new StringTokenizer(br.readLine()); }
				catch (Exception e) {}
			} return st.nextToken();
		}
		int nextInt() { return Integer.parseInt(next()); }
		long nextLong() { return Long.parseLong(next()); }
		double nextDouble() { return Double.parseDouble(next()); }
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Andy Phan
 */
public class f {
    public static void main(String[] args) {
        FS in = new FS(System.in);
        PrintWriter out = new PrintWriter(System.out);

        char[] s = (in.next()+"%").toCharArray();
        char[] t = (in.next()+"%").toCharArray();

        int sn = s.length-1;
        int tn = t.length-1;
        int mn = sn+tn;
        int[][][] dp = new int[sn+1][tn+1][mn+1];
        for(int i = 0; i <= mn; i++) dp[sn][tn][i] = i;
        for(int i = sn; i >= 0; i--) {
            for(int j = tn; j >= 0; j--) {
                if(i == sn && j == tn) continue;
                for(int k = mn; k >= 0; k--) {
                    dp[i][j][k] = 5*mn;
                    if(k != mn) {
                        dp[i][j][k] = Math.min(dp[i][j][k], dp[i+(s[i] == '(' ? 1 : 0)][j+(t[j] == '(' ? 1 : 0)][k+1]+1);
                    }
                    if((s[i] == ')' || t[j] == ')') && k != 0) {
                        dp[i][j][k] = Math.min(dp[i][j][k], dp[i+(s[i] == ')' ? 1 : 0)][j+(t[j] == ')' ? 1 : 0)][k-1]+1);
                    }
                }
            }
        }
        int i = 0;
        int j = 0;
        int k = 0;
        while(i < sn || j < tn) {
            if(k != mn) {
                if(dp[i][j][k] == dp[i+(s[i] == '(' ? 1 : 0)][j+(t[j] == '(' ? 1 : 0)][k+1]+1) {
                    i = i+(s[i] == '(' ? 1 : 0);
                    j = j+(t[j] == '(' ? 1 : 0);
                    k = k+1;
                    out.print('(');
                    continue;
                }
            }
            i = i+(s[i] == ')' ? 1 : 0);
            j = j+(t[j] == ')' ? 1 : 0);
            k = k-1;
            out.print(')');
        }
        while(k-->0) out.print(')');
        out.println();

        out.close();
    }

    static class FS {

        BufferedReader in;
        StringTokenizer token;

        public FS(InputStream str) {
            in = new BufferedReader(new InputStreamReader(str));
        }

        public String next() {
            if (token == null || !token.hasMoreElements()) {
                try {
                    token = new StringTokenizer(in.readLine());
                } catch (IOException ex) {
                }
                return next();
            }
            return token.nextToken();
        }

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

import java.util.Arrays;
import java.util.Scanner;

public class F {

	private static Scanner in;
	private static String s;
	private static String t;
	private static int[][][] dp;

	public static void main(String[] args) {
		in = new Scanner(System.in);
		s = in.next();
		t = in.next();
		int n = s.length();
		int m = t.length();
		dp = new int[n+1][m+1][n+m+2];
		for(int i=0; i<dp.length; i++) {
			for(int j=0; j<dp[0].length; j++) {
				Arrays.fill(dp[i][j], -1);
			}
		}
		int i = 0;
		int j = 0;
		int open = 0;
		StringBuilder sb = new StringBuilder();

		while(i!=n || j!=m) {
			int count1 = (i<s.length() && s.charAt(i)==')'?1:0);
			int count2 = (j<t.length() && t.charAt(j)==')'?1:0);
//			if (count1+count2!=0)
			if (solve(i, j, open)==1+solve(i+count1, j+count2, open-1)) {
				sb.append(')');
				i+=count1;
				j+=count2;
				open--;
			}
			count1 = (i<s.length() && s.charAt(i)=='('?1:0);
			count2 = (j<t.length() && t.charAt(j)=='('?1:0);
//			if (count1+count2!=0)
			if (solve(i, j, open)==1+solve(i+count1, j+count2, open+1)) {
				sb.append('(');
				i+=count1;
				j+=count2;
				open++;
			}
		}
		for(int x=0; x<open; x++) {
			sb.append(')');
		}
//		System.out.println(solve(0, 0, 0));
		System.out.println(sb.toString());
	}

	private static int solve(int i, int j, int open) {
		if (open>s.length()+t.length()) return (int)1e9;
//		System.out.println(i+" "+j+" "+open);
		if (open<0) return (int)1e9;
		if (i==s.length() && j==t.length()) {
			return open;
		}

		if (dp[i][j][open]!=-1) return dp[i][j][open];

		int ans = (int)1e9;

		int count1 = (i<s.length() && s.charAt(i)==')'?1:0);
		int count2 = (j<t.length() && t.charAt(j)==')'?1:0);
//		if (count1+count2!=0)
		ans = Math.min(ans, 1+solve(i+count1, j+count2, open-1));
		count1 = (i<s.length() && s.charAt(i)=='('?1:0);
		count2 = (j<t.length() && t.charAt(j)=='('?1:0);
//		if (count1+count2!=0)
		ans = Math.min(ans, 1+solve(i+count1, j+count2, open+1));

		return dp[i][j][open]=ans;

	}

}

import java.util.*;
import java.io.*;
public class Main {
      static class pair implements Comparable<pair>{
        int x;
        int y;
        public pair(int x, int y){
            this.x=x;
            this.y=y;
        }
        public int compareTo(pair p){
            return (x-p.x==0)?y-p.y:x-p.x;
        }}
     static char[] a,b;
     static int [][][]dp;
    static StringBuilder str;
     public static int solve( int i, int j , int need){
         if(i==a.length&&j==b.length&&need==0) return 0;
         if(need>=500) return (int) 1e9;
         if(dp[i][j][need]==-2) return (int)1e9;
         if(dp[i][j][need]!=-1) return dp[i][j][need];
         dp[i][j][need]= -2;
             int take = 1+solve((i==a.length)?i:(a[i]=='(')?Math.min(i+1,a.length):i,(j==b.length)?j:(b[j]=='(')?Math.min(j+1,b.length):j,need +1);
             int leave =(need>0)? 1+solve((i==a.length)?i:(a[i]==')')?Math.min(i+1,a.length):i,(j==b.length)?j:(b[j]==')')?Math.min(j+1,b.length):j,need -1):Integer.MAX_VALUE;
        return dp[i][j][need] = Math.min(take,leave);
     }
      public static void trace( int i, int j , int need){
         if(i==a.length&&j==b.length&&need==0) return;
         int req = solve(i,j,need);
         if( 1+dp[(i==a.length)?i:(a[i]=='(')?Math.min(i+1,a.length):i][(j==b.length)?j:(b[j]=='(')?Math.min(j+1,b.length):j][need +1]==dp[i][j][need]){
            str.append("(");
             trace((i==a.length)?i:(a[i]=='(')?Math.min(i+1,a.length):i,(j==b.length)?j:(b[j]=='(')?Math.min(j+1,b.length):j,need +1);
             return;
         }else{
             str.append(")");
         trace((i==a.length)?i:(a[i]==')')?Math.min(i+1,a.length):i,(j==b.length)?j:(b[j]==')')?Math.min(j+1,b.length):j,need -1);}
     }
  public static void main(String[] args) throws IOException,InterruptedException{
	BufferedReader	 br = new BufferedReader(new InputStreamReader(System.in));
	PrintWriter out = new PrintWriter(System.out);
     	// String s = br.readLine();
        // char[] arr=s.toCharArray();
        // ArrayList<Integer> arrl = new ArrayList<Integer>();
        // TreeSet<Integer> ts1 = new TreeSet<Integer>();
        // HashSet<Integer> h = new HashSet<Integer>();
        // HashMap<Integer, Integer> map= new HashMap<>();
        // PriorityQueue<String> pQueue = new PriorityQueue<String>();
        // LinkedList<String> object = new LinkedList<String>();
        // StringBuilder str = new StringBuilder();
 	  //  StringTokenizer   st = new StringTokenizer(br.readLine());
 	  // 	  n = Integer.parseInt(st.nextToken());
 	  String s = br.readLine();
 	  a = s.toCharArray();
 	  String t = br.readLine();
 	  b = t.toCharArray();
 	   	dp = new int[201][201][500];
 	   	for(int i=0; i<201; i++)
 	   	for(int j=0; j<201; j++)
 	   	  Arrays.fill(dp[i][j],-1);
 	   int ans =solve(0,0,0);
 	    str = new StringBuilder();
 	   trace(0,0,0);
 	   out.print(str);
 	   	  out.flush();
	}

}

import java.util.*;
import java.io.*;
public class Main {
      static class pair implements Comparable<pair>{
        int x;
        int y;
        public pair(int x, int y){
            this.x=x;
            this.y=y;
        }
        public int compareTo(pair p){
            return (x-p.x==0)?y-p.y:x-p.x;
        }}
     static char[] a,b;
     static int [][][]dp;
    static StringBuilder str;
     public static int solve( int i, int j , int need){
                  if(need>=500) return (int) 1e9;
         if(i==a.length&&j==b.length) return dp[i][j][need]= need;
         if(dp[i][j][need]!=-1) return dp[i][j][need];
             int take = 1+solve((i==a.length)?i:(a[i]=='(')?Math.min(i+1,a.length):i,(j==b.length)?j:(b[j]=='(')?Math.min(j+1,b.length):j,need +1);
             int leave =(need>0)? 1+solve((i==a.length)?i:(a[i]==')')?Math.min(i+1,a.length):i,(j==b.length)?j:(b[j]==')')?Math.min(j+1,b.length):j,need -1):Integer.MAX_VALUE;
        return dp[i][j][need] = Math.min(take,leave);
     }
      public static void trace( int i, int j , int need){
          if(i==a.length&&j==b.length){while(need-->0) str.append(")");  return;}
        // int req = solve(i,j,need);
         if( 1+dp[(i==a.length)?i:(a[i]=='(')?Math.min(i+1,a.length):i][(j==b.length)?j:(b[j]=='(')?Math.min(j+1,b.length):j][need +1]==dp[i][j][need]){
            str.append("(");
             trace((i==a.length)?i:(a[i]=='(')?Math.min(i+1,a.length):i,(j==b.length)?j:(b[j]=='(')?Math.min(j+1,b.length):j,need +1);
             return;
         }else{
             str.append(")");
         trace((i==a.length)?i:(a[i]==')')?Math.min(i+1,a.length):i,(j==b.length)?j:(b[j]==')')?Math.min(j+1,b.length):j,need -1);}
     }
  public static void main(String[] args) throws IOException,InterruptedException{
	BufferedReader	 br = new BufferedReader(new InputStreamReader(System.in));
	PrintWriter out = new PrintWriter(System.out);
     	// String s = br.readLine();
        // char[] arr=s.toCharArray();
        // ArrayList<Integer> arrl = new ArrayList<Integer>();
        // TreeSet<Integer> ts1 = new TreeSet<Integer>();
        // HashSet<Integer> h = new HashSet<Integer>();
        // HashMap<Integer, Integer> map= new HashMap<>();
        // PriorityQueue<String> pQueue = new PriorityQueue<String>();
        // LinkedList<String> object = new LinkedList<String>();
        // StringBuilder str = new StringBuilder();
 	  //  StringTokenizer   st = new StringTokenizer(br.readLine());
 	  // 	  n = Integer.parseInt(st.nextToken());
 	  String s = br.readLine();
 	  a = s.toCharArray();
 	  String t = br.readLine();
 	  b = t.toCharArray();
 	   	dp = new int[201][201][500];
 	   	for(int i=0; i<201; i++)
 	   	for(int j=0; j<201; j++)
 	   	  Arrays.fill(dp[i][j],-1);
 	   int ans =solve(0,0,0);
 	    str = new StringBuilder();
 	   trace(0,0,0);
 	   out.print(str);
 	   	  out.flush();
	}

}

import java.io.*;
import java.util.*;

/*
───────────────■■■─────────────────────────
──█▄─▄█─▄▀▀▀▄─█──▄█─────█──▄▀─▄▀▀▀▄─▀▀█▀▀──
──█─▀─█─█───█─█─█─█─────█■█───█───█───█────
──█───█─▀▄▄▄▀─█▀──█─────█──▀▄─▀▄▄▄▀───█────
───────────────────────────────────────────
*/

public class Main {

    static FastReader in;
    static PrintWriter out;
    static Random rand = new Random();
    static final int INF = (int) 1e9;
    static final int N = 202;
    static char[] s, t;
    static int[][][] dp;
    static Par[][][] par;

    static class Par {
        int i, j, k;
        char ch;

        Par(int i, int j, int k, char ch) {
            this.i = i;
            this.j = j;
            this.k = k;
            this.ch = ch;
        }
    }

    static void solve() {
        s = in.next().toCharArray();
        t = in.next().toCharArray();

        dp = new int[N][N][N];
        for (int i = 0; i <= s.length; i++) {
            for (int j = 0; j <= t.length; j++) {
                Arrays.fill(dp[i][j], INF);
            }
        }
        par = new Par[N][N][N];
        dp[0][0][0] = 0;
        for (int k = 1; k < N; k++) {
            dp[0][0][k] = k;
            par[0][0][k] = new Par(0, 0, k - 1, '(');
            //
        }

        for (int i = 0; i <= s.length; i++) {
            for (int j = 0; j <= t.length; j++) {
                for (int k = 0; k < N; k++) {
                    if (i > 0 && j > 0) {
                        if (s[i - 1] == t[j - 1]) {
                            if (s[i - 1] == '(') {
                                if (k > 0) {
                                    dp[i][j][k] = dp[i - 1][j - 1][k - 1] + 1;
                                    par[i][j][k] = new Par(i - 1, j - 1, k - 1, '(');
                                }
                            } else {
                                if (k < N - 1) {
                                    dp[i][j][k] = dp[i - 1][j - 1][k + 1] + 1;
                                    par[i][j][k] = new Par(i - 1, j - 1, k + 1, ')');
                                }
                            }
                        } else {
                            if (s[i - 1] == '(') {
                                if (k > 0 && k < N - 1) {
                                    if (dp[i - 1][j][k - 1] + 1 <= dp[i][j - 1][k + 1] + 1) {
                                        dp[i][j][k] = dp[i - 1][j][k - 1] + 1;
                                        par[i][j][k] = new Par(i - 1, j, k - 1, '(');
                                    } else {
                                        dp[i][j][k] = dp[i][j - 1][k + 1] + 1;
                                        par[i][j][k] = new Par(i, j - 1, k + 1, ')');
                                    }
                                } else if (k == 0) {
                                    dp[i][j][k] = dp[i][j - 1][k + 1] + 1;
                                    par[i][j][k] = new Par(i, j - 1, k + 1, ')');
                                } else if (k == N - 1) {
                                    dp[i][j][k] = dp[i - 1][j][k - 1] + 1;
                                    par[i][j][k] = new Par(i - 1, j, k - 1, '(');
                                }
                            } else {
                                if (k > 0 && k < N - 1) {
                                    if (dp[i][j - 1][k - 1] + 1 <= dp[i - 1][j][k + 1] + 1) {
                                        dp[i][j][k] = dp[i][j - 1][k - 1] + 1;
                                        par[i][j][k] = new Par(i, j - 1, k - 1, '(');
                                    } else {
                                        dp[i][j][k] = dp[i - 1][j][k + 1] + 1;
                                        par[i][j][k] = new Par(i - 1, j, k + 1, ')');
                                    }
                                } else if (k == 0) {
                                    dp[i][j][k] = dp[i - 1][j][k + 1] + 1;
                                    par[i][j][k] = new Par(i - 1, j, k + 1, ')');
                                } else if (k == N - 1) {
                                    dp[i][j][k] = dp[i][j - 1][k - 1] + 1;
                                    par[i][j][k] = new Par(i, j - 1, k - 1, '(');
                                }
                            }
                        }
                    } else if (i > 0) {
                        if (s[i - 1] == '(') {
                            if (k > 0) {
                                dp[i][j][k] = dp[i - 1][j][k - 1] + 1;
                                par[i][j][k] = new Par(i - 1, j, k - 1, '(');
                            }
                        } else {
                            if (k < N - 1) {
                                dp[i][j][k] = dp[i - 1][j][k + 1] + 1;
                                par[i][j][k] = new Par(i - 1, j, k + 1, ')');
                            }
                        }
                    } else if (j > 0) {
                        if (t[j - 1] == '(') {
                            if (k > 0) {
                                dp[i][j][k] = dp[i][j - 1][k - 1] + 1;
                                par[i][j][k] = new Par(i, j - 1, k - 1, '(');
                            }
                        } else {
                            if (k < N - 1) {
                                dp[i][j][k] = dp[i][j - 1][k + 1] + 1;
                                par[i][j][k] = new Par(i, j - 1, k + 1, ')');
                            }
                        }
                    }
                }
            }
        }
        int min = dp[s.length][t.length][0], mink = 0;
        Par p = par[s.length][t.length][0];
        for (int k = 1; k < N; k++) {
            if (dp[s.length][t.length][k] + k < min) {
                min = dp[s.length][t.length][k] + k;
                mink = k;
                p = par[s.length][t.length][k];
            }
        }

        StringBuilder ans = new StringBuilder();
        for (int i = 0; i < mink; i++) {
            ans.append(')');
        }
        while (p != null) {
            ans.insert(0, p.ch);
            p = par[p.i][p.j][p.k];
        }

//        out.println(min);
        out.println(ans.toString());
    }

    public static void main(String[] args) {
        in = new FastReader(System.in);
//        in = new FastReader(new FileInputStream("input.txt"));
        out = new PrintWriter(System.out);
//        out = new PrintWriter(new FileOutputStream("output.txt"));

        int q = 1;

        while (q-- > 0) {
            solve();
        }

        out.close();
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }

        Integer nextInt() {
            return Integer.parseInt(next());
        }

        Long nextLong() {
            return Long.parseLong(next());
        }

        Double nextDouble() {
            return Double.parseDouble(next());
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(nextLine());
            }
            return st.nextToken();
        }

        String nextLine() {
            String s = "";
            try {
                s = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return s;
        }
    }
}

import java.io.*;
import java.math.BigInteger;
import java.util.*;

// written by luchy0120

public class Main {
    public static void main(String[] args) throws Exception {

        new Main().run();
    }

//    int get_room(int i,int j){
//        return i/3*3 + j/3;
//    }

//    int a[][] = new int[9][9];
//    int space = 0;
//
//    boolean vis_row[][] = new boolean[9][10];
//    boolean vis_col[][] = new boolean[9][10];
//    boolean vis_room[][] = new boolean[9][10];
//    int val[][][] =new int[9][9][];
//    int prepare[][];
//
//    void dfs(int rt){
//
//    }
    char[] s1;
    int l1;

    char[] s2;
    int l2;
    int dp[][][];

    int go(int p1,int p2,int open){
        int ma =  1000000000;
        if(open>l1+l2) return ma;
        if(dp[p1][p2][open]>0) return dp[p1][p2][open];

        if(p1<l1&&p2<l2){

                if ('(' == s1[p1] && '(' == s2[p2]) {
                    ma = Math.min(ma, 1 + go(p1 + 1, p2 + 1, open + 1));
                } else if ('(' == s1[p1]) {
                    ma = Math.min(ma,1 + go(p1 + 1, p2, open + 1));
                } else if ('(' == s2[p2]) {
                    ma = Math.min(ma, 1 + go(p1, p2 + 1, open + 1));
                } else {
                    ma = Math.min(ma, 1 + go(p1, p2, open + 1));
                }

                if(open>0){

                    if (')' == s1[p1] && ')' == s2[p2]) {
                        ma = Math.min(ma, 1 + go(p1 + 1, p2 + 1, open - 1));
                    } else if (')' == s1[p1]) {
                        ma = Math.min(ma, 1 + go(p1 + 1, p2, open - 1));
                    } else if (')' == s2[p2]) {
                        ma = Math.min(ma, 1 + go(p1, p2 + 1, open - 1));
                    } else {
                        ma = Math.min(ma, 1 + go(p1, p2, open - 1));
                    }

                }

        }else if(p1<l1){

            if ('(' == s1[p1]) {
                ma = Math.min(ma, 1 + go(p1 + 1, p2, open + 1));
            }else{
                ma = Math.min(ma, 1 + go(p1 , p2, open + 1));
            }
            if(open>0){
                if (')' == s1[p1]) {
                    ma = Math.min(ma, 1 + go(p1 + 1, p2, open - 1));
                }else{
                    ma = Math.min(ma, 1 + go(p1 , p2, open - 1));
                }
            }

        }else if(p2<l2){

            if ('(' == s2[p2]) {
                ma = Math.min(ma, 1 + go(p1 , p2+1, open + 1));
            }else{
                ma = Math.min(ma, 1 + go(p1 , p2, open + 1));
            }
            if(open>0){
                if (')' == s2[p2]) {
                    ma = Math.min(ma, 1 + go(p1 , p2+1, open - 1));
                }else{
                    ma = Math.min(ma, 1 + go(p1 , p2, open - 1));
                }
            }
        }else if(open> 0){
            ma = Math.min(ma, 1 + go(p1 , p2, open - 1));
        }else{
            ma  = 0;
        }
        return dp[p1][p2][open] = ma;

    }

    void solve(){

         s1 = ns().toCharArray();
        s2 = ns().toCharArray();
        l1 = s1.length;
        l2 = s2.length;
        dp = new int[l1+1][l2+1][l1+l2+1];
        int s = go(0,0,0);

        int p1 = 0;
        int p2 = 0;
        int open = 0;

        int len = dp[0][0][0];

        StringBuilder sb  =new StringBuilder();

        while(len>0) {
            int np1 = p1;
            int np2 = p2;
            int nopen = open;

            if (p1 < l1 && s1[p1] == '(') {
                np1 = p1 + 1;
            }
            if (p2 < l2 && s2[p2] == '(') {
                np2 = p2 + 1;
            }
            nopen = open + 1;
            if (dp[np1][np2][nopen] == len - 1) {
                p1 =np1;p2 = np2;open = nopen; len--; sb.append('(');continue;
            }

             np1 = p1;
             np2 = p2;

            if(open>0) {
                if (p1 < l1 && s1[p1] == ')') {
                    np1 = p1 + 1;
                }
                if (p2 < l2 && s2[p2] == ')') {
                    np2 = p2 + 1;
                }
                nopen = open - 1;
                if (dp[np1][np2][nopen] == len - 1) {
                    p1 =np1;p2 = np2;open = nopen; len--; sb.append(')');continue;
                }
            }
        }
        println(sb);

    }
    public static String roundS(double result, int scale){
        String fmt = String.format("%%.%df", scale);
        return String.format(fmt, result);
    }

//    void solve() {
//
//        for(int i=0;i<9;++i) {
//            for (int j = 0; j < 9; ++j) {
//                int v = ni();
//                a[i][j] = v;
//                if(v>0) {
//                    vis_row[i][v] = true;
//                    vis_col[j][v] = true;
//                    vis_room[get_room(i, j)][v] = true;
//                }else{
//                    space++;
//                }
//            }
//        }
//
//
//        prepare = new int[space][2];
//
//        int p = 0;
//
//        for(int i=0;i<9;++i) {
//            for (int j = 0; j < 9; ++j) {
//                if(a[i][j]==0){
//                    prepare[p][0] = i;
//                    prepare[p][1]= j;p++;
//                    List<Integer> temp =new ArrayList<>();
//                    for(int k=1;k<=9;++k){
//                        if(!vis_col[j][k]&&!vis_row[i][k]&&!vis_room[get_room(i,j)][k]){
//                            temp.add(k);
//                        }
//                    }
//                    int sz = temp.size();
//                    val[i][j] = new int[sz];
//                    for(int k=0;k<sz;++k){
//                        val[i][j][k] = temp.get(k);
//                    }
//                }
//            }
//        }
//        Arrays.sort(prepare,(x,y)->{
//           return Integer.compare(val[x[0]][x[1]].length,val[y[0]][y[1]].length);
//        });
//        dfs(0);
//
//
//
//
//
//
//
//
//
//
//    }

    InputStream is;
    PrintWriter out;

    void run() throws Exception {
        is = System.in;
        out = new PrintWriter(System.out);
        solve();
        out.flush();
    }

    private byte[] inbuf = new byte[1024];
    public int lenbuf = 0, ptrbuf = 0;

    private int readByte() {
        if (lenbuf == -1) throw new InputMismatchException();
        if (ptrbuf >= lenbuf) {
            ptrbuf = 0;
            try {
                lenbuf = is.read(inbuf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (lenbuf <= 0) return -1;
        }
        return inbuf[ptrbuf++];
    }

    private boolean isSpaceChar(int c) {
        return !(c >= 33 && c <= 126);
    }

    private int skip() {
        int b;
        while ((b = readByte()) != -1 && isSpaceChar(b)) ;
        return b;
    }

    private double nd() {
        return Double.parseDouble(ns());
    }

    private char nc() {
        return (char) skip();
    }

    private char ncc() {
        int b = readByte();
        return (char) b;
    }

    private String ns() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    private char[] ns(int n) {
        char[] buf = new char[n];
        int b = skip(), p = 0;
        while (p < n && !(isSpaceChar(b))) {
            buf[p++] = (char) b;
            b = readByte();
        }
        return n == p ? buf : Arrays.copyOf(buf, p);
    }

    private String nline() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while (!isSpaceChar(b) || b == ' ') {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    private char[][] nm(int n, int m) {
        char[][] a = new char[n][];
        for (int i = 0; i < n; i++) a[i] = ns(m);
        return a;
    }

    private int[] na(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = ni();
        return a;
    }

    private long[] nal(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) a[i] = nl();
        return a;
    }

    private int ni() {
        int num = 0, b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) {
        }
        ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        while (true) {
            if (b >= '0' && b <= '9') num = (num << 3) + (num << 1) + (b - '0');
            else return minus ? -num : num;
            b = readByte();
        }
    }

    private long nl() {
        long num = 0;
        int b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) {
        }
        ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        while (true) {
            if (b >= '0' && b <= '9') num = num * 10 + (b - '0');
            else return minus ? -num : num;
            b = readByte();
        }
    }

    void print(Object obj) {
        out.print(obj);
    }

    void println(Object obj) {
        out.println(obj);
    }

    void println() {
        out.println();
    }

    void printArray(int a[],int from){
        int l = a.length;
        for(int i=from;i<l;++i){
            print(a[i]);
            if(i!=l-1){
                print(" ");
            }
        }
        println();
    }

    void printArray(long a[],int from){
        int l = a.length;
        for(int i=from;i<l;++i){
            print(a[i]);
            if(i!=l-1){
                print(" ");
            }
        }
        println();
    }
}

import java.util.*;
import java.io.*;
import java.text.*;

public class F1272 {

	static char[] a, b;

	static int[][][] dp;

	public static int dp(int i, int j, int cnt) {
		int ans = (int) 1e9;
		if (i == -1 && j == -1 && cnt == 0)
			return 0;
		if (cnt > 800)
			return (int) 1e9;
		if (dp[i + 1][j + 1][cnt] != -1)
			return dp[i + 1][j + 1][cnt];
		if (cnt > 0) {
			char c = '(';
			int nxti = i == -1 ? -1 : c == a[i] ? i - 1 : i;
			int nxtj = j == -1 ? -1 : c == b[j] ? j - 1 : j;
			nxti = Math.max(nxti, -1);
			nxtj = Math.max(nxtj, -1);
			ans = Math.min(ans, 1 + dp(nxti, nxtj, cnt - 1));
		}
		if (i != -1 || j != -1) {
			char c = ')';
			int nxti = i == -1 ? -1 : c == a[i] ? i - 1 : i;
			int nxtj = j == -1 ? -1 : c == b[j] ? j - 1 : j;
			ans = Math.min(ans, 1 + dp(nxti, nxtj, cnt + 1));
		}
		return dp[i + 1][j + 1][cnt] = ans;
	}

	static Stack<Character> st;

	public static void trace(int i, int j, int cnt) {
//		System.out.println(i+" "+j+" "+cnt);
		if (i == -1 && j == -1 && cnt == 0)
			return;
		boolean bb = false;
		if (cnt > 0) {
			char c = '(';
			int nxti = i == -1 ? -1 : c == a[i] ? i - 1 : i;
			int nxtj = j == -1 ? -1 : c == b[j] ? j - 1 : j;

			if (dp(i, j, cnt) == 1 + dp(nxti, nxtj, cnt - 1)) {
				st.add(c);
				bb = true;
				trace(nxti, nxtj, cnt - 1);
			}
		}
		if (!bb) {
			char c = ')';
			int nxti = i == -1 ? -1 : c == a[i] ? i - 1 : i;
			int nxtj = j == -1 ? -1 : c == b[j] ? j - 1 : j;
			if (dp(i, j, cnt) == 1 + dp(nxti, nxtj, cnt + 1)) {
				st.add(c);
				trace(nxti, nxtj, cnt + 1);
			}
		}

	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		a = sc.next().toCharArray();
		b = sc.next().toCharArray();
		dp = new int[a.length + 1][b.length + 1][1000];
		for (int[][] x : dp) {
			for (int[] y : x)
				Arrays.fill(y, -1);
		}
		st = new Stack<Character>();
//		pw.println(dp(a.length - 1, b.length - 1, 0));
		trace(a.length - 1, b.length - 1, 0);

		while (!st.isEmpty()) {
			pw.print(st.pop());
		}
		pw.close();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

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

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

		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();
		}

	}
}

import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    static final int UNCALC = -1, N = 900, INF = (int) 1e9, vis = -2;
    static char[] s, t;
    static int n, m;
    static int[][][] memo;
    static StringBuilder ans;

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        s = sc.next().toCharArray();
        t = sc.next().toCharArray();
        n = s.length;
        m = t.length;
        memo = new int[n + 1][m + 1][N];
        for (int[][] a : memo)
            for (int[] b : a)
                Arrays.fill(b, UNCALC);
        ans = new StringBuilder();
        trace(0,0,0);
        out.println(ans);
        out.flush();
        out.close();
    }

    static void trace(int i, int j, int open) {
        if (i == n && j == m && open == 0) return;
        int best = dp(i, j, open);
        if (1 + dp(getNextS(i, '('), getNextT(j, '('), open + 1) == best) {
            ans.append("(");
            trace(getNextS(i, '('), getNextT(j, '('), open + 1);
            return;
        }
        ans.append(")");
        trace(getNextS(i, ')'), getNextT(j, ')'), open - 1);

    }

    static int dp(int i, int j, int open) {
        if (open >= N) return INF;
        if (i == n && j == m && open == 0) return 0;
        if (memo[i][j][open] == vis) return INF;
        if (memo[i][j][open] != UNCALC) return memo[i][j][open];
        memo[i][j][open] = vis;
        int min = 1 + dp(getNextS(i, '('), getNextT(j, '('), open + 1);
        if (open != 0) min = Math.min(min, 1 + dp(getNextS(i, ')'), getNextT(j, ')'), open - 1));
        return memo[i][j][open] = min;
    }

    static int getNextS(int i, char x) {
        if (i == n) return i;
        return s[i] == x ? (i + 1) : i;
    }

    static int getNextT(int i, char x) {
        if (i == m) return i;
        return t[i] == x ? (i + 1) : i;
    }

    static class Scanner {

        StringTokenizer st;
        BufferedReader br;

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

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

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

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

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        public char nextChar() throws IOException {
            return next().charAt(0);
        }

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

        public int[] nextIntArray(int n) throws IOException {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) throws IOException {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }

        public Integer[] nextIntegerArray(int n) throws IOException {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public double[] nextDoubleArray(int n) throws IOException {
            double[] ans = new double[n];
            for (int i = 0; i < n; i++)
                ans[i] = nextDouble();
            return ans;
        }

        public short nextShort() throws IOException {
            return Short.parseShort(next());
        }

    }

}

// Don't place your source in a package
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;

// Please name your class Main
public class Main {

	static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));

    static int read() throws IOException {
        in.nextToken();
        return (int) in.nval;
    }
    static String readString() throws IOException {
        in.nextToken();
        return in.sval;
	}

	public static void main (String[] args) throws java.lang.Exception {
	    Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		//InputReader in = new InputReader(System.in);

		int T=1;

		for(int t=0;t<T;t++){
			String s=in.next();
			String tt=in.next();
			Solution sol=new Solution();
			sol.solution(s,tt);
		}

		out.flush();
	}

}

class Solution{
	//constant variable
	final int MAX=Integer.MAX_VALUE;
	final int MIN=Integer.MIN_VALUE;
	//Set<Integer>adjecent[];
	//////////////////////////////

	String s,t;
	int dp[][][];
	public void solution(String s,String t){
		StringBuilder res=new StringBuilder();
		this.s=s;
		this.t=t;
		dp=new int[s.length()+1][t.length()+1][800];
		for(int i=0;i<dp.length;i++){
			for(int j=0;j<dp[0].length;j++){
				Arrays.fill(dp[i][j],-1);
			}
		}
		int min=dfs(0,0,0);

		int I=0,J=0,K=0;

		//msg(dp[2][1][2]+"");

		while(min>0){
			//msg(I+"  "+J+"  "+K+"  "+min);
			if(I<s.length()&&J<t.length()){
				if(s.charAt(I)==t.charAt(J)){
					if(s.charAt(I)=='('&&dp[I+1][J+1][K+1]==min-1){
						res.append(s.charAt(I));
						I++;J++;K++;min--;
						continue;
					}
					if(K>0&&s.charAt(I)==')'&&dp[I+1][J+1][K-1]==min-1){
						res.append(s.charAt(I));
						I++;J++;K--;min--;
						continue;
					}

				}
			}

			if(I<s.length()){
				if(s.charAt(I)=='('){
					if(dp[I+1][J][K+1]==min-1){
						res.append(s.charAt(I));
						I++;K++;
						min--;
						continue;
					}
				}else{
					if(K>0&&dp[I+1][J][K-1]==min-1){
						res.append(s.charAt(I));
						I++;K--;
						min--;
						continue;
					}
				}
			}
			if(J<t.length()){
				if(t.charAt(J)=='('){
					if(dp[I][J+1][K+1]==min-1){
						res.append(t.charAt(J));
						J++;K++;
						min--;
						continue;
					}
				}else{
					if(K>0&&dp[I][J+1][K-1]==min-1){
						res.append(t.charAt(J));
						J++;K--;
						min--;
						continue;
					}
				}
			}
			if(K+1<dp[0][0].length&&dp[I][J][K+1]==min-1){
				res.append("(");
				K++;
				min--;
				continue;
			}

			break;
		}

		for(int i=0;i<K;i++){
			res.append(")");
		}

		msg(res.toString());
	}

	public int dfs(int i,int j,int k){

		if(i>=s.length()&&j>=t.length()){
			dp[i][j][k]=k;
			return k;
		}

		if(dp[i][j][k]!=-1)return dp[i][j][k];

		int res=MAX;
		if(i<s.length()){
			char c=s.charAt(i);
			if(c=='('){
				res=Math.min(res,1+dfs(i+1,j,k+1));
			}else{
				if(k>0){
					res=Math.min(res,1+dfs(i+1,j,k-1));
				}
			}
		}
		if(j<t.length()){
			char c=t.charAt(j);
			if(c=='('){
				res=Math.min(res,1+dfs(i,j+1,k+1));
			}else{
				if(k>0){
					res=Math.min(res,1+dfs(i,j+1,k-1));
				}
			}
		}

		if(i<s.length()&&j<t.length()){
			if(s.charAt(i)==t.charAt(j)){
				if(s.charAt(i)=='(')res=Math.min(res,1+dfs(i+1,j+1,k+1));
				else{
					if(k>0)res=Math.min(res,1+dfs(i+1,j+1,k-1));
				}
			}
		}

		if(k+1<s.length()+t.length()+1){
			res=Math.min(res,1+dfs(i,j,k+1));
		}
		dp[i][j][k]=res;
		return res;
	}

	public void swap(int A[],int l,int r){
		int t=A[l];
		A[l]=A[r];
		A[r]=t;
	}

	public long C(long fact[],int i,int j){ // C(20,3)=20!/(17!*3!)
		// take   a/b     where a=20!  b=17!*3!
		if(j>i)return 0;
		if(j==0)return 1;
		long mod=998244353;
		long a=fact[i];
		long b=((fact[i-j]%mod)*(fact[j]%mod))%mod;
		BigInteger B= BigInteger.valueOf(b);
		long binverse=B.modInverse(BigInteger.valueOf(mod)).longValue();
		return ((a)*(binverse%mod))%mod;
	}

	//map operation
	public void put(Map<Integer,Integer>map,int i){
		if(!map.containsKey(i))map.put(i,0);
		map.put(i,map.get(i)+1);
	}

	public void delete(Map<Integer,Integer>map,int i){
		map.put(i,map.get(i)-1);
		if(map.get(i)==0)map.remove(i);
	}

	/*public void tarjan(int p,int r){
		if(cut)return;
		List<Integer>childs=adjecent[r];
		dis[r]=low[r]=time;
		time++;

		//core for tarjan
		int son=0;
		for(int c:childs){
			if(ban==c||c==p)continue;
			if(dis[c]==-1){
				son++;
				tarjan(r,c);
				low[r]=Math.min(low[r],low[c]);
				if((r==root&&son>1)||(low[c]>=dis[r]&&r!=root)){
					cut=true;
					return;
				}
			}else{
				if(c!=p){
					low[r]=Math.min(low[r],dis[c]);
				}
			}
		}

	}*/

	//helper function I would use
	public void remove(Map<Integer,Integer>map,int i){
		map.put(i,map.get(i)-1);
		if(map.get(i)==0)map.remove(i);
	}

	public void ascii(String s){
		for(char c:s.toCharArray()){
			System.out.print((c-'a')+" ");
		}
		msg("");
	}

	public int flip(int i){
		if(i==0)return 1;
		else return 0;
	}

	public boolean[] primes(int n){
		boolean A[]=new boolean[n+1];
		for(int i=2;i<=n;i++){
			if(A[i]==false){
				for(int j=i+i;j<=n;j+=i){
					A[j]=true;
				}
			}
		}
		return A;
	}

	public void msg(String s){
		System.out.println(s);
	}

	public void msg1(String s){
		System.out.print(s);
	}

	public int[] kmpPre(String p){
		int pre[]=new int[p.length()];
		int l=0,r=1;
		while(r<p.length()){
			if(p.charAt(l)==p.charAt(r)){
				pre[r]=l+1;
				l++;r++;
			}else{
				if(l==0)r++;
				else l=pre[l-1];
			}
		}
		return pre;
	}

	public boolean isP(String s){
		int l=0,r=s.length()-1;
		while(l<r){
			if(s.charAt(l)!=s.charAt(r))return false;
			l++;r--;
		}
		return true;
	}

	public int find(int nums[],int x){//union find => find method
		if(nums[x]==x)return x;
		int root=find(nums,nums[x]);
		nums[x]=root;
		return root;
	}

	public int get(int A[],int i){
		if(i<0||i>=A.length)return 0;
		return A[i];
	}
	public int[] copy1(int A[]){
		int a[]=new int[A.length];
		for(int i=0;i<a.length;i++)a[i]=A[i];
		return a;
	}

	public void print1(int A[]){
		for(long i:A)System.out.print(i+" ");
		System.out.println();
	}
	public void print2(long A[][]){
		for(int i=0;i<A.length;i++){
			for(int j=0;j<A[0].length;j++){
				System.out.print(A[i][j]+" ");
			}System.out.println();
		}
	}

	public int min(int a,int b){
		return Math.min(a,b);
	}

	public int[][] matrixdp(int[][] grid) {
        if(grid.length==0)return new int[][]{};
        int res[][]=new int[grid.length][grid[0].length];
        for(int i=0;i<grid.length;i++){
            for(int j=0;j<grid[0].length;j++){
                res[i][j]=grid[i][j]+get(res,i-1,j)+get(res,i,j-1)-get(res,i-1,j-1);
            }
        }
        return res;
    }

    public int get(int grid[][],int i,int j){
        if(i<0||j<0||i>=grid.length||j>=grid[0].length)return 0;
        return grid[i][j];
    }

	public int[] suffixArray(String s){
		int n=s.length();
		Suffix A[]=new Suffix[n];

		for(int i=0;i<n;i++){
			A[i]=new Suffix(i,s.charAt(i)-'a',0);
		}

		for(int i=0;i<n;i++){
			if(i==n-1){
				A[i].next=-1;
			}else{
				A[i].next=A[i+1].rank;
			}
		}
		Arrays.sort(A);

		for(int len=4;len<A.length*2;len<<=1){
			int in[]=new int[A.length];
			int rank=0;
			int pre=A[0].rank;
			A[0].rank=rank;
			in[A[0].index]=0;
			for(int i=1;i<A.length;i++){//rank for the first two letter
				if(A[i].rank==pre&&A[i].next==A[i-1].next){
					pre=A[i].rank;
					A[i].rank=rank;
				}else{
					pre=A[i].rank;
					A[i].rank=++rank;
				}
				in[A[i].index]=i;
			}

			for(int i=0;i<A.length;i++){
				int next=A[i].index+len/2;
				if(next>=A.length){
					A[i].next=-1;
				}else{
					A[i].next=A[in[next]].rank;
				}
			}

			Arrays.sort(A);
		}

		int su[]=new int[A.length];
		for(int i=0;i<su.length;i++){
			su[i]=A[i].index;
		}
		return su;
	}

}

//suffix array Struct
class Suffix implements Comparable<Suffix>{
	int index;
	int rank;
	int next;
	public Suffix(int i,int rank,int next){
		this.index=i;
		this.rank=rank;
		this.next=next;
	}

	@Override
	public int compareTo(Suffix other) {
		if(this.rank==other.rank){
			return this.next-other.next;
		}
		return this.rank-other.rank;
	}

	public String toString(){
		return this.index+"   "+this.rank+"   "+this.next+"  ";
	}
}

class Wrapper implements Comparable<Wrapper>{
	int spf;int cnt;
	public Wrapper(int spf,int cnt){
		this.spf=spf;
		this.cnt=cnt;
	}

	@Override
	public int compareTo(Wrapper other) {
		return this.spf-other.spf;
	}
}

    class Node{//what the range would be for that particular node
		boolean state=false;
        int l=0,r=0;
		int ll=0,rr=0;
        public Node(boolean state){
            this.state=state;
        }
    }

	class Seg1{
			int A[];
			public Seg1(int A[]){
				this.A=A;
			}

			public void update(int left,int right,int val,int s,int e,int id){
				if(left<0||right<0||left>right)return;
				if(left==s&&right==e){

					A[id]+=val;
					return;
				}
				int mid=s+(e-s)/2; //[s,mid] [mid+1,e]

				if(left>=mid+1){
					update(left,right,val,mid+1,e,id*2+2);
				}else if(right<=mid){
					update(left,right,val,s,mid,id*2+1);
				}else{
					update(left,mid,val,s,mid,id*2+1);
					update(mid+1,right,val,mid+1,e,id*2+2);
				}
			}

			public int query(int i,int add,int s,int e,int id){

				if(s==e&&i==s){
					return A[id]+add;
				}

				int mid=s+(e-s)/2; //[s,mid] [mid+1,e]

				if(i>=mid+1){
					return query(i,A[id]+add,mid+1,e,id*2+2);
				}else{
					return query(i,A[id]+add,s,mid,id*2+1);
				}
			}
	}

	 class MaxFlow{

		  public static List<Edge>[] createGraph(int nodes) {
			List<Edge>[] graph = new List[nodes];
			for (int i = 0; i < nodes; i++)
			  graph[i] = new ArrayList<>();
			return graph;
		  }

		  public static void addEdge(List<Edge>[] graph, int s, int t, int cap) {
			graph[s].add(new Edge(t, graph[t].size(), cap));
			graph[t].add(new Edge(s, graph[s].size() - 1, 0));
		  }

		  static boolean dinicBfs(List<Edge>[] graph, int src, int dest, int[] dist) {
			Arrays.fill(dist, -1);
			dist[src] = 0;
			int[] Q = new int[graph.length];
			int sizeQ = 0;
			Q[sizeQ++] = src;
			for (int i = 0; i < sizeQ; i++) {
			  int u = Q[i];
			  for (Edge e : graph[u]) {
				if (dist[e.t] < 0 && e.f < e.cap) {
				  dist[e.t] = dist[u] + 1;
				  Q[sizeQ++] = e.t;
				}
			  }
			}
			return dist[dest] >= 0;
		  }

		  static int dinicDfs(List<Edge>[] graph, int[] ptr, int[] dist, int dest, int u, int f) {
			if (u == dest)
			  return f;
			for (; ptr[u] < graph[u].size(); ++ptr[u]) {
			  Edge e = graph[u].get(ptr[u]);
			  if (dist[e.t] == dist[u] + 1 && e.f < e.cap) {
				int df = dinicDfs(graph, ptr, dist, dest, e.t, Math.min(f, e.cap - e.f));
				if (df > 0) {
				  e.f += df;
				  graph[e.t].get(e.rev).f -= df;
				  return df;
				}
			  }
			}
			return 0;
		  }

		  public static int maxFlow(List<Edge>[] graph, int src, int dest) {
			int flow = 0;
			int[] dist = new int[graph.length];
			while (dinicBfs(graph, src, dest, dist)) {
			  int[] ptr = new int[graph.length];
			  while (true) {
				int df = dinicDfs(graph, ptr, dist, dest, src, Integer.MAX_VALUE);
				if (df == 0)
				  break;
				flow += df;
			  }
			}
			return flow;
		  }

	 }

	 	 class Edge {
			int t, rev, cap, f;

			public Edge(int t, int rev, int cap) {
			  this.t = t;
			  this.rev = rev;
			  this.cap = cap;
			}
		  }

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        FTwoBracketSequences solver = new FTwoBracketSequences();
        solver.solve(1, in, out);
        out.close();
    }

    static class FTwoBracketSequences {
        static char[] first;
        static char[] second;
        static Integer[][][] memo;

        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            first = sc.next().toCharArray();
            second = sc.next().toCharArray();
            memo = new Integer[201][201][402];
            pw.println(trace(0, 0, 0));
        }

        private int dp(int i, int j, int k) {
            if (k < 0)
                return (int) 1e9;
            if (i == first.length && j == second.length)
                return k;
            if (k > 400)
                return (int) 1e9;
            if (memo[i][j][k] != null)
                return memo[i][j][k];
            int jj = j < second.length && second[j] == '(' ? j + 1 : j;
            int ii = i < first.length && first[i] == '(' ? i + 1 : i;
            int open = 1 + dp(ii, jj, k + 1);
            jj = j < second.length && second[j] == ')' ? j + 1 : j;
            ii = i < first.length && first[i] == ')' ? i + 1 : i;
            int close = 1 + dp(ii, jj, k - 1);
            return memo[i][j][k] = Math.min(open, close);
        }

        private String trace(int i, int j, int k) {
            if (i == first.length && j == second.length) {
                StringBuilder temp = new StringBuilder();
                while (k-- > 0)
                    temp.append(')');
                return temp.toString();
            }
            int cur = dp(i, j, k);
            int jj = j < second.length && second[j] == '(' ? j + 1 : j;
            int ii = i < first.length && first[i] == '(' ? i + 1 : i;
            int open = 1 + dp(ii, jj, k + 1);
            if (cur == 1 + dp(ii, jj, k + 1))
                return '(' + trace(ii, jj, k + 1);
            else {
                jj = j < second.length && second[j] == ')' ? j + 1 : j;
                ii = i < first.length && first[i] == ')' ? i + 1 : i;
                return ')' + trace(ii, jj, k - 1);
            }
        }

    }

    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() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

    }
}

import java.io.*;
import java.util.*;

public class Main {
	static char[]in1;
	static char[]in2;
	static int[][][]memo;
	static int dp(int i,int j,int pref) {
		if(i>=in1.length) {
			int inc=0;
			while(j<in2.length) {
				pref+=in2[j]=='('?1:-1;
				inc++;
				if(pref<0) {
					pref=0;inc++;
				}
				j++;
			}
			return inc+pref;
		}
		if(j>=in2.length) {
			int inc=0;
			while(i<in1.length) {
				pref+=in1[i]=='('?1:-1;
				inc++;
				if(pref<0) {
					pref=0;inc++;
				}
				i++;
			}
			return inc+pref;
		}
		if(memo[i][j][pref]!=-1)return memo[i][j][pref];
		int f=in1[i]=='('?1:-1;
		int s=in2[j]=='('?1:-1;
		int ans=(int)1e7;
		if(pref+f<0) {
			ans=Math.min(ans, dp(i+1,j,0)+2);
		}
		else {
			ans=Math.min(ans, dp(i+1,j,pref+f)+1);
		}

		if(pref+s<0) {
			ans=Math.min(ans, dp(i,j+1,0)+2);
		}
		else {
			ans=Math.min(ans, dp(i,j+1,pref+s)+1);
		}

		if(s==f) {
			if(pref+s<0) {
				ans=Math.min(ans, dp(i+1,j+1,0)+2);
			}
			else {
				ans=Math.min(ans, dp(i+1,j+1,pref+s)+1);
			}
		}
		else {
			if(pref+f<0) {
				ans=Math.min(ans, dp(i+1,j+1,0)+3);
			}
			else {
				ans=Math.min(ans, dp(i+1,j+1,pref+f+s)+2);
			}

			if(pref+s<0) {
				ans=Math.min(ans, dp(i+1,j+1,0)+3);
			}
			else {
				ans=Math.min(ans, dp(i+1,j+1,pref+f+s)+2);
			}
		}
		return memo[i][j][pref]=ans;
	}
	static StringBuilder anss;
	static void trace(int i,int j,int pref) {
		if(i>=in1.length) {
			int inc=0;
			while(j<in2.length) {
				pref+=in2[j]=='('?1:-1;
				anss.append(in2[j]);
				if(pref<0) {
					pref=0;inc++;
				}
				j++;
			}
			StringBuilder ex=new StringBuilder();
			while(inc>0) {
				inc--;
				ex.append('(');
			}
			anss=new StringBuilder(ex.append(anss));
			while(pref>0) {
				anss.append(')');pref--;
			}
			return;
		}
		if(j>=in2.length) {
			int inc=0;
			while(i<in1.length) {
				pref+=in1[i]=='('?1:-1;
				anss.append(in1[i]);
				if(pref<0) {
					pref=0;inc++;
				}
				i++;
			}
			StringBuilder ex=new StringBuilder();
			while(inc>0) {
				inc--;
				ex.append('(');
			}
			anss=new StringBuilder(ex.append(anss));
			while(pref>0) {
				anss.append(')');pref--;
			}
			return;
		}
		int f=in1[i]=='('?1:-1;
		int s=in2[j]=='('?1:-1;
		int ans=dp(i,j,pref);
		if(pref+f<0) {
			if(ans==dp(i+1,j,0)+2) {
				anss.append(in1[i]);
				StringBuilder ex=new StringBuilder('(');

				anss=new StringBuilder(ex.append(anss));
				trace(i+1,j,0);
				return;
			}
		}
		else {
			if(ans==dp(i+1,j,pref+f)+1) {
				anss.append(in1[i]);

				trace(i+1,j,pref+f);

				return;
			}
		}

		if(pref+s<0) {
			if(ans==dp(i,j+1,0)+2) {
				anss.append(in2[j]);
				StringBuilder ex=new StringBuilder('(');

				anss=new StringBuilder(ex.append(anss));
				trace(i,j+1,0);
				return;
			}
		}
		else {
			if(ans==dp(i,j+1,pref+s)+1) {
				anss.append(in2[j]);

				trace(i,j+1,pref+s);
				return;
			}
		}

		if(s==f) {
			if(pref+s<0) {
				if(ans==dp(i,j+1,0)+2) {
					anss.append(in2[j]);
					StringBuilder ex=new StringBuilder('(');

					anss=new StringBuilder(ex.append(anss));
					trace(i+1,j+1,0);
					return;
				}
			}
			else {
				if(ans==dp(i+1,j+1,pref+s)+1) {
					anss.append(in2[j]);

					trace(i+1,j+1,pref+s);
					return;
				}
			}
		}
		else {
			if(pref+f<0) {
				if(ans==dp(i+1,j+1,0)+3) {
					anss.append(in1[i]+""+in2[j]);
					StringBuilder ex=new StringBuilder('(');

					anss=new StringBuilder(ex.append(anss));
					trace(i+1,j+1,0);
					return;
				}
			}
			else {
				if(ans==dp(i+1,j+1,pref+s+f)+2) {
					anss.append(in1[i]+""+in2[j]);

					trace(i+1,j+1,pref+s+f);
					return;
				}
			}

			if(pref+s<0) {
				if(ans==dp(i+1,j+1,0)+3) {
					anss.append(in2[j]+""+in1[i]);
					StringBuilder ex=new StringBuilder('(');

					anss=new StringBuilder(ex.append(anss));
					trace(i+1,j+1,0);
					return;
				}
			}
			else {
				if(ans==dp(i+1,j+1,pref+s+f)+2) {
					anss.append(in2[j]+""+in1[i]);

					trace(i+1,j+1,pref+s+f);
				}
			}

		}
	}
	public static void main(String[] args) throws Exception {
		MScanner sc = new MScanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		in1=sc.nextLine().toCharArray();
		in2=sc.nextLine().toCharArray();
		memo=new int[in1.length][in2.length][Math.max(in1.length, in2.length)+1];
		for(int [][]i:memo) {
			for(int j[]:i) {
				Arrays.fill(j, -1);
			}
		}
		anss=new StringBuilder();

		dp(0,0,0);
		trace(0,0,0);
		pw.println(anss);
		pw.flush();
	}
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;

		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

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

		public int[] takearr(int n) throws IOException {
			int[] in = new int[n];
			for (int i = 0; i < n; i++)
				in[i] = nextInt();
			return in;
		}

		public long[] takearrl(int n) throws IOException {
			long[] in = new long[n];
			for (int i = 0; i < n; i++)
				in[i] = nextLong();
			return in;
		}

		public Integer[] takearrobj(int n) throws IOException {
			Integer[] in = new Integer[n];
			for (int i = 0; i < n; i++)
				in[i] = nextInt();
			return in;
		}

		public Long[] takearrlobj(int n) throws IOException {
			Long[] in = new Long[n];
			for (int i = 0; i < n; i++)
				in[i] = nextLong();
			return in;
		}

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

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

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

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

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

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class Code {
	static String[][][] dp = new String[250][250][250];
	public static String f(String s1,String s2,int a,int b,int c) {
		if(c>200)return "";
		if(a==s1.length()&&b==s2.length()) {
			String t = "";
			if(c>0) {
				while(c-->0)
					t+=")";
			}
			return t;
		}
		if(dp[a][b][c]!=null)return dp[a][b][c];
		if(a<s1.length()&&b<s2.length()) {
			String t1 = '('+f(s1,s2,(s1.charAt(a)=='(')?a+1:a,(s2.charAt(b)=='(')?b+1:b,c+1);
			String t2=t1;
			if(c>0)
				t2 = ')'+f(s1,s2,(s1.charAt(a)==')')?a+1:a,(s2.charAt(b)==')')?b+1:b,c-1);
			if(t1.length()<t2.length())
				return dp[a][b][c] = t1;
			else
				return dp[a][b][c] = t2;
		}else if(a<s1.length()&&b>=s2.length()) {
			String t1 = '('+f(s1,s2,(s1.charAt(a)=='(')?a+1:a,b,c+1);
			String t2=t1;
			if(c>0)
				t2 = ')'+f(s1,s2,(s1.charAt(a)==')')?a+1:a,b,c-1);
			if(t1.length()<t2.length())
				return dp[a][b][c] =t1;
			else
				return dp[a][b][c] =t2;
		}else if(a>=s1.length()&&b<s2.length()) {
			String t1 = '('+f(s1,s2,a,(s2.charAt(b)=='(')?b+1:b,c+1);
			String t2=t1;
			if(c>0)
				t2 = ')'+f(s1,s2,a,(s2.charAt(b)==')')?b+1:b,c-1);
			if(t1.length()<t2.length())
				return dp[a][b][c] =t1;
			else
				return dp[a][b][c] =t2;
		}
		return "";

	}
	public static void main(String[] args) throws IOException{
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		String s1 = sc.next();
		String s2 = sc.next();
		System.out.println(f(s1,s2,0,0,0));
		pw.flush();
		pw.close();
	}
}
class A1 implements Comparable<A1>{
	long a;long b;long value;
	public A1(long f,long g) {
		a = f;
		b = g;
		value = a*b;
	}
	@Override
	public int compareTo(A1 o) {
		// TODO Auto-generated method stub
		if(value>o.value)return 1;
		if(value<o.value)return -1;
		return 0;
	}
}
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();

    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Sparsh Sanchorawala
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        FTwoBracketSequences solver = new FTwoBracketSequences();
        solver.solve(1, in, out);
        out.close();
    }

    static class FTwoBracketSequences {
        char[] a;
        char[] b;
        int n;
        int m;
        int[][][] dp;
        char[][][] val;

        void recur(int i, int j, int k) {
            dp[i][j][k] = (int) 1e5;
            int ni = i, nj = j;
            if (a[i] == ')')
                ni--;
            if (b[j] == ')')
                nj--;
            if (k + 1 <= 2 * (n + m)) {
                recur(ni, nj, k + 1);
                if (dp[ni][nj][k + 1] == -1)
                    recur(ni, nj, k + 1);
                if (dp[ni][nj][k + 1] + 1 < dp[i][j][k]) {
                    dp[i][j][k] = dp[ni][nj][k + 1] + 1;
                    val[i][j][k] = ')';
                }

            }
            ni = i;
            nj = j;
            if (a[i] == '(')
                ni--;
            if (b[j] == '(')
                nj--;
            if (k - 1 >= 0) {
                if (dp[ni][nj][k - 1] == -1)
                    recur(ni, nj, k - 1);
                if (dp[ni][nj][k - 1] + 1 < dp[i][j][k]) {
                    dp[i][j][k] = dp[ni][nj][k - 1] + 1;
                    val[i][j][k] = '(';
                }
            }
        }

        public void solve(int testNumber, InputReader s, PrintWriter w) {
            a = (" " + s.next()).toCharArray();
            b = (" " + s.next()).toCharArray();
            n = a.length - 1;
            m = b.length - 1;
            dp = new int[n + 1][m + 1][2 * (n + m) + 1];
            val = new char[n + 1][m + 1][2 * (n + m) + 1];
            for (int i = 0; i <= n; i++)
                for (int j = 0; j <= m; j++)
                    for (int k = 0; k <= n + m; k++)
                        dp[i][j][k] = -1;
            dp[0][0][0] = 0;
            recur(n, m, 0);
            int i = n, j = m, k = 0;
            StringBuffer sb = new StringBuffer();
            while (!(i == 0 && j == 0 && k == 0)) {
                sb.append(val[i][j][k]);
                if (val[i][j][k] == ')') {
                    if (a[i] == ')')
                        i--;
                    if (b[j] == ')')
                        j--;
                    k++;
                } else {
                    if (a[i] == '(')
                        i--;
                    if (b[j] == '(')
                        j--;
                    k--;
                }
            }
            sb.reverse();
            w.println(sb.toString());
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public String nextString() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                if (Character.isValidCodePoint(c)) {
                    res.appendCodePoint(c);
                }
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return nextString();
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}

import java.io.*;
import java.util.*;

public class Problem_F {
	static final int INF = Integer.MAX_VALUE / 2;
	static char[] S, T;;
	static int[][] dp, dp2, dp3;

	public static void solve(int type, int i, int j) {
		int x, y;
		x = i - 1 + type % 2;
		y = j - (type + 1) / 2;
		if ((type % 2 == 0 ? S[i] : T[j]) == '(') {
			if (dp[i][j] > dp[x][y] + 1) {
				dp[i][j] = dp[x][y] + 1;
				dp2[i][j] = dp2[x][y] + 1;
				dp3[i][j] = type;
			}
		} else if (dp2[x][y] == 0) {
			if (dp[i][j] > dp[x][y] + 2) {
				dp[i][j] = dp[x][y] + 2;
				dp2[i][j] = 0;
				dp3[i][j] = type;
			}
		} else {
			if (dp[i][j] > dp[x][y] + 1) {
				dp[i][j] = dp[x][y] + 1;
				dp2[i][j] = dp2[x][y] - 1;
				dp3[i][j] = type;
			}
		}
	}

	public static void main(String[] args) {
		InputReader in = new InputReader();
		StringBuilder out = new StringBuilder();

		S = (" " + in.nextLine()).toCharArray();
		T = (" " + in.nextLine()).toCharArray();
		dp = new int[S.length][T.length];
		dp2 = new int[S.length][T.length];
		dp3 = new int[S.length][T.length];
		for (int i = 0; i < S.length; i++) {
			Arrays.fill(dp[i], INF);
		}
		dp[0][0] = 0;
		for (int i = 0; i < S.length; i++) {
			for (int j = i == 0 ? 1 : 0; j < T.length; j++) {
				if (i > 0) {
					solve(0, i, j);
				}
				if (j > 0) {
					solve(1, i, j);
				}
				if (i > 0 && j > 0 && S[i] == T[j]) {
					solve(2, i, j);
				}
			}
		}
		for (int i = dp2[S.length - 1][T.length - 1]; i > 0; i--) {
			out.append(')');
		}
		int x = S.length - 1;
		int y = T.length - 1;
		while (x > 0 || y > 0) {
			if (dp3[x][y] == 0) {
				out.append(S[x]);
				if (S[x] == ')' && dp2[x - 1][y] == 0) {
					out.append('(');
				}
				x--;
			} else if (dp3[x][y] == 1) {
				out.append(T[y]);
				if (T[y] == ')' && dp2[x][y - 1] == 0) {
					out.append('(');
				}
				y--;
			} else {
				out.append(S[x]);
				if (S[x] == ')' && dp2[x - 1][y - 1] == 0) {
					out.append('(');
				}
				x--;
				y--;
			}
		}
		out.reverse().append('\n');

		System.out.print(out);
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer st;

		public InputReader() {
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

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

		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}

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

/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class x1272F
   {
      static int[][][] dp;
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         String input1 = infile.readLine();
         String input2 = infile.readLine();
         char[] a = input1.toCharArray();
         char[] b = input2.toCharArray();
         int N = a.length;
         int M = b.length;
         dp = new int[N+M+5][N+1][M+1];
         //I have a brain tumor
         //bal, # of processed chars for each string
         Node[][][] parent = new Node[N+M+5][N+1][M+1];
         for(int i=0; i <= N+M; i++)
            for(int a1=0; a1 <= N; a1++)
               for(int b1=0; b1 <= M; b1++)
                  dp[i][a1][b1] = 6969;
         dp[0][0][0] = 0;
         for(int i=0; i <= N; i++)
            for(int j=0; j <= M; j++)
               for(int bal=0; bal <= N+M; bal++)
                  if(dp[bal][i][j] != 6969)
                  {
                     int x = N;
                     if(i < N)
                        x = i+Math.max(0, val(a[i]));
                     int y = M;
                     if(j < M)
                        y = j+Math.max(0, val(b[j]));
                     if(dp[bal+1][x][y] > dp[bal][i][j]+1)
                     {
                        dp[bal+1][x][y] = dp[bal][i][j]+1;
                        parent[bal+1][x][y] = new Node(bal,i,j);
                     }
                     x = N;
                     if(i < N)
                        x = i+Math.max(0, -1*val(a[i]));
                     y = M;
                     if(j < M)
                        y = j+Math.max(0, -1*val(b[j]));
                     if(bal > 0 && dp[bal-1][x][y] > dp[bal][i][j]+1)
                     {
                        dp[bal-1][x][y] = dp[bal][i][j]+1;
                        parent[bal-1][x][y] = new Node(bal,i,j);
                     }
                  }
         int curr = 0;
         for(int i=1; i <= N+M; i++)
            if(dp[i][N][M]+i < dp[curr][N][M]+curr)
               curr = i;
         int d = curr;
         int e = N;
         int f = M;
         StringBuilder sb = new StringBuilder();
         for(int i=0; i < curr; i++)
            sb.append("(");
         while(parent[d][e][f] != null)
         {
            Node par = parent[d][e][f];
            if(par.bal < d)
               sb.append(")");
            else
               sb.append("(");
            d = par.bal;
            e = par.x;
            f = par.y;
         }
         //System.out.println(dp[curr][N][M]+curr);
         System.out.println(sb.reverse());
      }
      public static int val(char c)
      {
         if(c == '(')
            return 1;
         return -1;
      }
   }
   class Node
   {
      public int bal;
      public int x;
      public int y;

      public Node(int a, int b, int c)
      {
         bal = a;
         x = b;
         y = c;
      }
   }

/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class x1272F
   {
      static int[][][] dp;
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         String input1 = infile.readLine();
         String input2 = infile.readLine();
         char[] a = input1.toCharArray();
         char[] b = input2.toCharArray();
         int N = a.length;
         int M = b.length;
         dp = new int[N+M+5][N+1][M+1];
         //I have a brain tumor
         //bal, # of processed chars for each string
         Node[][][] parent = new Node[N+M+5][N+1][M+1];
         for(int i=0; i <= N+M; i++)
            for(int a1=0; a1 <= N; a1++)
               for(int b1=0; b1 <= M; b1++)
                  dp[i][a1][b1] = 6969;
         dp[0][0][0] = 0;
         for(int i=0; i <= N; i++)
            for(int j=0; j <= M; j++)
               for(int bal=0; bal <= N+M; bal++)
                  if(dp[bal][i][j] != 6969)
                  {
                     int x = N;
                     if(i < N)
                        x = i+Math.max(0, val(a[i]));
                     int y = M;
                     if(j < M)
                        y = j+Math.max(0, val(b[j]));
                     if(dp[bal+1][x][y] > dp[bal][i][j]+1)
                     {
                        dp[bal+1][x][y] = dp[bal][i][j]+1;
                        parent[bal+1][x][y] = new Node(bal,i,j);
                     }
                     x = N;
                     if(i < N)
                        x = i+Math.max(0, -1*val(a[i]));
                     y = M;
                     if(j < M)
                        y = j+Math.max(0, -1*val(b[j]));
                     if(bal > 0 && dp[bal-1][x][y] > dp[bal][i][j]+1)
                     {
                        dp[bal-1][x][y] = dp[bal][i][j]+1;
                        parent[bal-1][x][y] = new Node(bal,i,j);
                     }
                  }
         int curr = 0;
         for(int i=1; i <= N+M; i++)
            if(dp[i][N][M]+i < dp[curr][N][M]+curr)
               curr = i;
         int d = curr;
         int e = N;
         int f = M;
         StringBuilder sb = new StringBuilder();
         for(int i=0; i < curr; i++)
            sb.append("(");
         while(parent[d][e][f] != null)
         {
            Node par = parent[d][e][f];
            if(par.bal < d)
               sb.append(")");
            else
               sb.append("(");
            d = par.bal;
            e = par.x;
            f = par.y;
         }
         //System.out.println(dp[curr][N][M]+curr);
         System.out.println(sb);
      }
      public static int val(char c)
      {
         if(c == '(')
            return 1;
         return -1;
      }
   }
   class Node
   {
      public int bal;
      public int x;
      public int y;

      public Node(int a, int b, int c)
      {
         bal = a;
         x = b;
         y = c;
      }
   }

/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class x1272F
   {
      static int[][][] dp;
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         String input1 = infile.readLine();
         String input2 = infile.readLine();
         char[] a = input1.toCharArray();
         char[] b = input2.toCharArray();
         int N = a.length;
         int M = b.length;
         dp = new int[N+M+5][N+1][M+1];
         //I have a brain tumor
         //bal, # of processed chars for each string
         Node[][][] parent = new Node[N+M+5][N+1][M+1];
         for(int i=0; i <= N+M; i++)
            for(int a1=0; a1 <= N; a1++)
               for(int b1=0; b1 <= M; b1++)
                  dp[i][a1][b1] = 6969;
         dp[0][0][0] = 0;
         for(int i=0; i <= N; i++)
            for(int j=0; j <= M; j++)
               for(int bal=0; bal <= N+M; bal++)
                  if(dp[bal][i][j] != 6969)
                  {
                     int x = N;
                     if(i < N)
                        x = i+Math.max(0, val(a[i]));
                     int y = M;
                     if(j < M)
                        y = j+Math.max(0, val(b[j]));
                     if(dp[bal+1][x][y] > dp[bal][i][j]+1)
                     {
                        dp[bal+1][x][y] = dp[bal][i][j]+1;
                        parent[bal+1][x][y] = new Node(bal,i,j);
                     }
                     x = N;
                     if(i < N)
                        x = i+Math.max(0, -1*val(a[i]));
                     y = M;
                     if(j < M)
                        y = j+Math.max(0, -1*val(b[j]));
                     if(bal > 0 && dp[bal-1][x][y] > dp[bal][i][j]+1)
                     {
                        dp[bal-1][x][y] = dp[bal][i][j]+1;
                        parent[bal-1][x][y] = new Node(bal,i,j);
                     }
                  }
         int curr = 0;
         for(int i=1; i <= N+M; i++)
            if(dp[i][N][M]+i < dp[curr][N][M]+curr)
               curr = i;
         int d = curr;
         int e = N;
         int f = M;
         StringBuilder sb = new StringBuilder();
         for(int i=0; i < curr; i++)
            sb.append("(");
         while(parent[d][e][f] != null)
         {
            Node par = parent[d][e][f];
            if(par.bal < d)
               sb.append(")");
            else
               sb.append("(");
            d = par.bal;
            e = par.x;
            f = par.y;
         }
         System.out.println(dp[curr][N][M]+curr);
         System.out.println(sb);
      }
      public static int val(char c)
      {
         if(c == '(')
            return 1;
         return -1;
      }
   }
   class Node
   {
      public int bal;
      public int x;
      public int y;

      public Node(int a, int b, int c)
      {
         bal = a;
         x = b;
         y = c;
      }
   }

import java.util.Arrays;
import java.util.Scanner;

public class F {

	private static Scanner in;
	private static String s;
	private static String t;
	private static int[][][] dp;

	public static void main(String[] args) {
		in = new Scanner(System.in);
		s = in.next();
		t = in.next();
		int n = s.length();
		int m = t.length();
		dp = new int[n+1][m+1][n+m+2];
		for(int i=0; i<dp.length; i++) {
			for(int j=0; j<dp[0].length; j++) {
				Arrays.fill(dp[i][j], -1);
			}
		}
		int i = 0;
		int j = 0;
		int open = 0;
		StringBuilder sb = new StringBuilder();

		while(i!=n || j!=m) {
			int count1 = (i<s.length() && s.charAt(i)==')'?1:0);
			int count2 = (j<t.length() && t.charAt(j)==')'?1:0);
//			if (count1+count2!=0)
			if (solve(i, j, open)==1+solve(i+count1, j+count2, open-1)) {
				sb.append(')');
				i+=count1;
				j+=count2;
				open--;
			}
			count1 = (i<s.length() && s.charAt(i)=='('?1:0);
			count2 = (j<t.length() && t.charAt(j)=='('?1:0);
//			if (count1+count2!=0)
			if (solve(i, j, open)==1+solve(i+count1, j+count2, open+1)) {
				sb.append('(');
				i+=count1;
				j+=count2;
				open++;
			}
		}
		for(int x=0; x<open; x++) {
			sb.append(')');
		}
		System.out.println(solve(0, 0, 0));
		System.out.println(sb.toString());
	}

	private static int solve(int i, int j, int open) {
		if (open>s.length()+t.length()) return (int)1e9;
//		System.out.println(i+" "+j+" "+open);
		if (open<0) return (int)1e9;
		if (i==s.length() && j==t.length()) {
			return open;
		}

		if (dp[i][j][open]!=-1) return dp[i][j][open];

		int ans = (int)1e9;

		int count1 = (i<s.length() && s.charAt(i)==')'?1:0);
		int count2 = (j<t.length() && t.charAt(j)==')'?1:0);
//		if (count1+count2!=0)
		ans = Math.min(ans, 1+solve(i+count1, j+count2, open-1));
		count1 = (i<s.length() && s.charAt(i)=='('?1:0);
		count2 = (j<t.length() && t.charAt(j)=='('?1:0);
//		if (count1+count2!=0)
		ans = Math.min(ans, 1+solve(i+count1, j+count2, open+1));

		return dp[i][j][open]=ans;

	}

}

import java.io.*;
import java.math.BigInteger;
import java.util.*;

// written by luchy0120

public class Main {
    public static void main(String[] args) throws Exception {

        new Main().run();
    }

//    int get_room(int i,int j){
//        return i/3*3 + j/3;
//    }

//    int a[][] = new int[9][9];
//    int space = 0;
//
//    boolean vis_row[][] = new boolean[9][10];
//    boolean vis_col[][] = new boolean[9][10];
//    boolean vis_room[][] = new boolean[9][10];
//    int val[][][] =new int[9][9][];
//    int prepare[][];
//
//    void dfs(int rt){
//
//    }
    char[] s1;
    int l1;

    char[] s2;
    int l2;
    int dp[][][];

    int go(int p1,int p2,int open){
        int ma =  1000000000;
        if(open>l1+l2) return ma;
        if(dp[p1][p2][open]>0) return dp[p1][p2][open];

        if(p1<l1&&p2<l2){

                if ('(' == s1[p1] && '(' == s2[p2]) {
                    ma = Math.min(ma, 1 + go(p1 + 1, p2 + 1, open + 1));
                } else if ('(' == s1[p1]) {
                    ma = Math.min(ma,1 + go(p1 + 1, p2, open + 1));
                } else if ('(' == s2[p2]) {
                    ma = Math.min(ma, 1 + go(p1, p2 + 1, open + 1));
                } else {
                    ma = Math.min(ma, 1 + go(p1, p2, open + 1));
                }

                if(open>0){

                    if (')' == s1[p1] && ')' == s2[p2]) {
                        ma = Math.min(ma, 1 + go(p1 + 1, p2 + 1, open - 1));
                    } else if (')' == s1[p1]) {
                        ma = Math.min(ma, 1 + go(p1 + 1, p2, open - 1));
                    } else if (')' == s2[p2]) {
                        ma = Math.min(ma, 1 + go(p1, p2 + 1, open - 1));
                    } else {
                        ma = Math.min(ma, 1 + go(p1, p2, open - 1));
                    }

                }

        }else if(p1<l1){

            if ('(' == s1[p1]) {
                ma = Math.min(ma, 1 + go(p1 + 1, p2, open + 1));
            }else{
                ma = Math.min(ma, 1 + go(p1 , p2, open + 1));
            }
            if(open>0){
                if (')' == s1[p1]) {
                    ma = Math.min(ma, 1 + go(p1 + 1, p2, open - 1));
                }else{
                    ma = Math.min(ma, 1 + go(p1 , p2, open - 1));
                }
            }

        }else if(p2<l2){

            if ('(' == s2[p2]) {
                ma = Math.min(ma, 1 + go(p1 , p2+1, open + 1));
            }else{
                ma = Math.min(ma, 1 + go(p1 , p2, open + 1));
            }
            if(open>0){
                if (')' == s2[p2]) {
                    ma = Math.min(ma, 1 + go(p1 , p2+1, open - 1));
                }else{
                    ma = Math.min(ma, 1 + go(p1 , p2, open - 1));
                }
            }
        }else if(open> 0){
            ma = open-1;
        }else{
            ma  = 0;
        }
        return dp[p1][p2][open] = ma;

    }

    void solve(){

         s1 = ns().toCharArray();
        s2 = ns().toCharArray();
        l1 = s1.length;
        l2 = s2.length;
        dp = new int[l1+1][l2+1][l1+l2+1];
        int s = go(0,0,0);

        int p1 = 0;
        int p2 = 0;
        int open = 0;

        int len = dp[0][0][0];

        StringBuilder sb  =new StringBuilder();

        while(len>0) {
            int np1 = p1;
            int np2 = p2;
            int nopen = open;

            if (p1 < l1 && s1[p1] == '(') {
                np1 = p1 + 1;
            }
            if (p2 < l2 && s2[p2] == '(') {
                np2 = p2 + 1;
            }
            nopen = open + 1;
            if (dp[np1][np2][nopen] == len - 1) {
                p1 =np1;p2 = np2;open = nopen; len--; sb.append('(');continue;
            }

             np1 = p1;
             np2 = p2;

            if(open>0) {
                if (p1 < l1 && s1[p1] == ')') {
                    np1 = p1 + 1;
                }
                if (p2 < l2 && s2[p2] == ')') {
                    np2 = p2 + 1;
                }
                nopen = open - 1;
                if (dp[np1][np2][nopen] == len - 1) {
                    p1 =np1;p2 = np2;open = nopen; len--; sb.append(')');continue;
                }
            }
        }
        println(sb);

    }
    public static String roundS(double result, int scale){
        String fmt = String.format("%%.%df", scale);
        return String.format(fmt, result);
    }

//    void solve() {
//
//        for(int i=0;i<9;++i) {
//            for (int j = 0; j < 9; ++j) {
//                int v = ni();
//                a[i][j] = v;
//                if(v>0) {
//                    vis_row[i][v] = true;
//                    vis_col[j][v] = true;
//                    vis_room[get_room(i, j)][v] = true;
//                }else{
//                    space++;
//                }
//            }
//        }
//
//
//        prepare = new int[space][2];
//
//        int p = 0;
//
//        for(int i=0;i<9;++i) {
//            for (int j = 0; j < 9; ++j) {
//                if(a[i][j]==0){
//                    prepare[p][0] = i;
//                    prepare[p][1]= j;p++;
//                    List<Integer> temp =new ArrayList<>();
//                    for(int k=1;k<=9;++k){
//                        if(!vis_col[j][k]&&!vis_row[i][k]&&!vis_room[get_room(i,j)][k]){
//                            temp.add(k);
//                        }
//                    }
//                    int sz = temp.size();
//                    val[i][j] = new int[sz];
//                    for(int k=0;k<sz;++k){
//                        val[i][j][k] = temp.get(k);
//                    }
//                }
//            }
//        }
//        Arrays.sort(prepare,(x,y)->{
//           return Integer.compare(val[x[0]][x[1]].length,val[y[0]][y[1]].length);
//        });
//        dfs(0);
//
//
//
//
//
//
//
//
//
//
//    }

    InputStream is;
    PrintWriter out;

    void run() throws Exception {
        is = System.in;
        out = new PrintWriter(System.out);
        solve();
        out.flush();
    }

    private byte[] inbuf = new byte[1024];
    public int lenbuf = 0, ptrbuf = 0;

    private int readByte() {
        if (lenbuf == -1) throw new InputMismatchException();
        if (ptrbuf >= lenbuf) {
            ptrbuf = 0;
            try {
                lenbuf = is.read(inbuf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (lenbuf <= 0) return -1;
        }
        return inbuf[ptrbuf++];
    }

    private boolean isSpaceChar(int c) {
        return !(c >= 33 && c <= 126);
    }

    private int skip() {
        int b;
        while ((b = readByte()) != -1 && isSpaceChar(b)) ;
        return b;
    }

    private double nd() {
        return Double.parseDouble(ns());
    }

    private char nc() {
        return (char) skip();
    }

    private char ncc() {
        int b = readByte();
        return (char) b;
    }

    private String ns() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    private char[] ns(int n) {
        char[] buf = new char[n];
        int b = skip(), p = 0;
        while (p < n && !(isSpaceChar(b))) {
            buf[p++] = (char) b;
            b = readByte();
        }
        return n == p ? buf : Arrays.copyOf(buf, p);
    }

    private String nline() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while (!isSpaceChar(b) || b == ' ') {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    private char[][] nm(int n, int m) {
        char[][] a = new char[n][];
        for (int i = 0; i < n; i++) a[i] = ns(m);
        return a;
    }

    private int[] na(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = ni();
        return a;
    }

    private long[] nal(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) a[i] = nl();
        return a;
    }

    private int ni() {
        int num = 0, b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) {
        }
        ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        while (true) {
            if (b >= '0' && b <= '9') num = (num << 3) + (num << 1) + (b - '0');
            else return minus ? -num : num;
            b = readByte();
        }
    }

    private long nl() {
        long num = 0;
        int b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) {
        }
        ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        while (true) {
            if (b >= '0' && b <= '9') num = num * 10 + (b - '0');
            else return minus ? -num : num;
            b = readByte();
        }
    }

    void print(Object obj) {
        out.print(obj);
    }

    void println(Object obj) {
        out.println(obj);
    }

    void println() {
        out.println();
    }

    void printArray(int a[],int from){
        int l = a.length;
        for(int i=from;i<l;++i){
            print(a[i]);
            if(i!=l-1){
                print(" ");
            }
        }
        println();
    }

    void printArray(long a[],int from){
        int l = a.length;
        for(int i=from;i<l;++i){
            print(a[i]);
            if(i!=l-1){
                print(" ");
            }
        }
        println();
    }
}

import java.util.*;
import java.io.*;
import java.text.*;

public class F1272 {

	static char[] a, b;

	static int[][][] dp;

	public static int dp(int i, int j, int cnt) {
		int ans = (int) 1e9;
		if (i == -1 && j == -1 && cnt == 0)
			return 0;
		if (cnt < -400 || cnt > 400)
			return -(int) 1e9;
		if (dp[i + 1][j + 1][cnt + 400] != -1) {
			return dp[i + 1][j + 1][cnt + 400];
		}
		if (i >= 0 && j >= 0 && a[i] == b[j])
			ans = Math.min(ans, 1 + dp(i - 1, j - 1, cnt + (a[i] == '(' ? 1 : -1)));
		if (i >= 0)
			ans = Math.min(ans, 1 + dp(i - 1, j, cnt + (a[i] == '(' ? 1 : -1)));
		if (j >= 0)
			ans = Math.min(ans, 1 + dp(i, j - 1, cnt + (b[j] == '(' ? 1 : -1)));
		if (cnt > 0)
			ans = Math.min(ans, 1 + dp(i, j, cnt - 1));
		if (cnt < 0)
			ans = Math.min(ans, 1 + dp(i, j, cnt + 1));
		return dp[i + 1][j + 1][cnt + 400] = ans;
	}

	static Stack<Character> st;

	public static void trace(int i, int j, int cnt) {
//		System.out.println(i+" "+j+" "+cnt);
		if (i == -1 && j == -1 && cnt == 0)
			return;
		if (i>=0 && j>=0 && a[i] == b[j] && dp(i, j, cnt) == 1 + dp(i - 1, j - 1, cnt + (a[i] == '(' ? 1 : -1)))
		{
			st.add(a[i]);
			trace(i - 1, j - 1, cnt + (a[i] == '(' ? 1 : -1));
		}
		else if (i >= 0 && dp(i, j, cnt) == 1 + dp(i - 1, j, cnt + (a[i] == '(' ? 1 : -1)))
		{
			st.add(a[i]);
			trace(i - 1, j, cnt + (a[i] == '(' ? 1 : -1));
		}
		else if (j >= 0 && dp(i, j, cnt) == 1 + dp(i, j - 1, cnt + (b[j] == '(' ? 1 : -1)))
		{
			st.add(b[j]);
			trace(i, j - 1, cnt + (b[i] == '(' ? 1 : -1));
		}
		else if (cnt > 0 && dp(i, j, cnt) == 1 + dp(i, j, cnt - 1)) {
			st.add(')');
			trace(i, j, cnt - 1);
		}
		else {
			st.add('(');
			trace(i,j,cnt+1);
		}
	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		a = sc.next().toCharArray();
		b = sc.next().toCharArray();
		dp = new int[a.length + 1][b.length + 1][1000];
		for (int[][] x : dp) {
			for (int[] y : x)
				Arrays.fill(y, -1);
		}
		st = new Stack<Character>();
//		pw.println(dp(a.length - 1, b.length - 1, 0));
		trace(a.length - 1, b.length - 1, 0);

		while (!st.isEmpty()) {
			pw.print(st.pop());
		}
		pw.close();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

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

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

		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();
		}

	}
}