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

Recall what is the regular bracket sequence:

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



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

Input

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

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

Output

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

Examples

Input


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


Output


(())()()


Input


)
((


Output


(())


Input


)
)))


Output


((()))


Input


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


Output


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

Solution (in JAVA):

Solution:
import java.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);
		}
	}
}