p01841 Rooted Tree for Misawa-san
C --Misawa's rooted tree

Problem Statement

You noticed that your best friend Misawa's birthday was near, and decided to give him a rooted binary tree as a gift. Here, the rooted binary tree has the following graph structure. (Figure 1)

* Each vertex has exactly one vertex called the parent of that vertex, which is connected to the parent by an edge. However, only one vertex, called the root, has no parent as an exception.
* Each vertex has or does not have exactly one vertex called the left child. If you have a left child, it is connected to the left child by an edge, and the parent of the left child is its apex.
* Each vertex has or does not have exactly one vertex called the right child. If you have a right child, it is connected to the right child by an edge, and the parent of the right child is its apex.

<image>



Figure 1. An example of two rooted binary trees and their composition

You wanted to give a handmade item, so I decided to buy two commercially available rooted binary trees and combine them on top of each other to make one better rooted binary tree. Each vertex of the two trees you bought has a non-negative integer written on it. Mr. Misawa likes a tree with good cost performance, such as a small number of vertices and large numbers, so I decided to create a new binary tree according to the following procedure.

1. Let the sum of the integers written at the roots of each of the two binary trees be the integers written at the roots of the new binary tree.
2. If both binary trees have a left child, create a binary tree by synthesizing each of the binary trees rooted at them, and use it as the left child of the new binary tree root. Otherwise, the root of the new bifurcation has no left child.
3. If the roots of both binaries have the right child, create a binary tree by synthesizing each of the binary trees rooted at them, and use it as the right child of the root of the new binary tree. Otherwise, the root of the new bifurcation has no right child.



You decide to see what the resulting rooted binary tree will look like before you actually do the compositing work. Given the information of the two rooted binary trees you bought, write a program to find the new rooted binary tree that will be synthesized according to the above procedure.

Here, the information of the rooted binary tree is expressed as a character string in the following format.

> (String representing the left child) [Integer written at the root] (String representing the right child)

A tree without nodes is an empty string. For example, the synthesized new rooted binary tree in Figure 1 is `(() [6] ()) [8] (((() [4] ()) [7] ()) [9] () ) `Written as.

Input

The input is expressed in the following format.

$ A $
$ B $

$ A $ and $ B $ are character strings that represent the information of the rooted binary tree that you bought, and the length is $ 7 $ or more and $ 1000 $ or less. The information given follows the format described above and does not include extra whitespace. Also, rooted trees that do not have nodes are not input. You can assume that the integers written at each node are greater than or equal to $ 0 $ and less than or equal to $ 1000 $. However, note that the integers written at each node of the output may not fall within this range.

Output

Output the information of the new rooted binary tree created by synthesizing the two rooted binary trees in one line. In particular, be careful not to include extra whitespace characters other than line breaks at the end of the line.

Sample Input 1


((() [8] ()) [2] ()) [5] (((() [2] ()) [6] (() [3] ())) [1] ())
(() [4] ()) [3] (((() [2] ()) [1] ()) [8] (() [3] ()))

Output for the Sample Input 1


(() [6] ()) [8] (((() [4] ()) [7] ()) [9] ())

Sample Input 2


(() [1] ()) [2] (() [3] ())
(() [1] (() [2] ())) [3] ()

Output for the Sample Input 2


(() [2] ()) [5] ()

Sample Input 3


(() [1] ()) [111] ()
() [999] (() [9] ())

Output for the Sample Input 3


() [1110] ()

Sample Input 4


(() [2] (() [4] ())) [8] ((() [16] ()) [32] (() [64] ()))
((() [1] ()) [3] ()) [9] (() [27] (() [81] ()))

Output for the Sample Input 4


(() [5] ()) [17] (() [59] (() [145] ()))

Sample Input 5


() [0] ()
() [1000] ()

Output for the Sample Input 5


() [1000] ()





Example

Input

((()[8]())[2]())[5](((()[2]())[6](()[3]()))[1]())
(()[4]())[3](((()[2]())[1]())[8](()[3]()))


Output

(()[6]())[8](((()[4]())[7]())[9]())
```python
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    a = S()
    b = S()

    def f(s):
        if not s:
            return None
        if s[0] != '(':
            return int(s)
        c = 1
        mi = -1
        for i in range(1, len(s)):
            if s[i] == '(':
                c += 1
            elif s[i] == ')':
                c -= 1
                if c == 0:
                    mi = i
                    break

        c = 1
        ki = -1
        for i in range(mi+2, len(s)):
            if s[i] == '[':
                c += 1
            elif s[i] == ']':
                c -= 1
                if c == 0:
                    ki = i
                    break

        return [f(s[mi+2:ki]), f(s[1:mi]), f(s[ki+2:-1])]

    fa = f(a)
    fb = f(b)
    def g(a, b):
        if a is None or b is None:
            return None
        if isinstance(a, int) or isinstance(b, int):
            ai = a
            while not isinstance(ai, int):
                ai = ai[0]

            bi = b
            while not isinstance(bi, int):
                bi = bi[0]

            return ai + bi

        return [g(a[i],b[i]) for i in range(3)]

    def h(a):
        if a is None:
            return ''
        if isinstance(a, int):
            return str(a)
        return '({})[{}]({})'.format(h(a[1]),h(a[0]),h(a[2]))


    return h(g(fa, fb))


print(main())


```