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 PYTHON3):

Solution:
import sys
import time
   
def play(s1, s2):
    #start_time = time.time()
    n = len(s1)
    m = len(s2)

    # баланс скобок не может быть > 200 (всегда можно построить правильную последовательность, не обяхателбно минимальной длины с балансом
    # < 200)
    maxBalance = 200

    #print(time.time() - start_time)

    #start_time = time.time()
    dp = []
    p = []
    for i in range (0, n + 1):
        dp.append([])
        p.append([])
        for j in range (0, m + 1):
            dp[i].append([])
            p[i].append([])
            for a in range (0, maxBalance + 1):
                dp[i][j].append(sys.maxsize)
                p[i][j].append(None)

    #dp = [[[{'len': sys.maxsize, 'i': 0, 'j': 0, 'a': 0, 'c': ''} for a in range(maxBalance + 1)] for i in range(m + 1)] for j in range(n + 1)]

    #print(time.time() - start_time)

    # dp[i][j][a] - это минимальная длина итоговой последовательности после прочтения 
    # i символов строки s1,
    # j символов строки s2,
    # a - баланс скобок (количество открытых, но не закрытых скобок)

    #start_time = time.time()
    dp[0][0][0] = 0
    #print(time.time() - start_time)

    #start_time = time.time()
    for i in range(0, n + 1):
        for j in range(0, m + 1):
            for a in range(0, maxBalance + 1):
                if dp[i][j][a] == sys.maxsize:
                    continue

                # сейчас мы находимся в следующем положении:
                # 1. В позиции i строки s1 (длина i + 1)
                # 2. В позицию j строки s2 (длина j + 1)
                # 3. имеем баланс a

                # Возможны всегда 2 варианта действия:
                # Добавляем в выходную строку '(' или ')'

                # Добавляем '('  => баланс увеличится на 1. Если в s1 открывающаяся скобка, то можем дигаться по ней далее
                # но если же там была закрывающаяся скобка, то стоим где сейчас. Поэтому:

                next_i = i + (i < n and s1[i] == '(')
                next_j = j + (j < m and s2[j] == '(')
                
                if a < maxBalance and dp[next_i][next_j][a + 1] > dp[i][j][a] + 1: 
                    dp[next_i][next_j][a + 1] = dp[i][j][a] + 1
                    p[next_i][next_j][a + 1] = (i, j, a, '(')

                # Второй вариант - добавление ')'. Рассуждения аналогичны. При добавлении закрывающей скобки баланс всегда уменьшается на 1
                next_i = i + (i < n and s1[i] == ')')
                next_j = j + (j < m and s2[j] == ')')
                
                if a > 0 and dp[next_i][next_j][a - 1] > dp[i][j][a] + 1: 
                    dp[next_i][next_j][a - 1] = dp[i][j][a] + 1
                    p[next_i][next_j][a - 1] = (i, j, a, ')')
    
    #print(time.time() - start_time)

    aa = 0
    nn = n
    mm = m

    #start_time = time.time()
    for a in range(0, maxBalance + 1):
        if dp[n][m][a] + a < dp[n][m][aa] + aa:
            aa = a
    #print(time.time() - start_time)

    #start_time = time.time()
    ret = ')' * aa
    while nn > 0 or mm > 0 or aa > 0:
        d = p[nn][mm][aa]
        nn = d[0]
        mm = d[1]
        aa = d[2]
        ret += d[3]

    #print(time.time() - start_time)
    return ret[::-1]

def main():
    #start_time = time.time()
    #print(play(input(), input()))
    print(play(input(), input()))
    #print(time.time() - start_time)
main()
#print(play('(())(()','()))()'))
#print(play('((',')'))