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

Solution:
#include <bits/stdc++.h>
using namespace std;
struct node {
  int i, j, k;
};
ostream& operator<<(ostream& dout, node& x) {
  dout << x.i << " " << x.j << " " << x.k << "\n";
  return dout;
}
int main() {
  string s, t;
  cin >> s >> t;
  int m = s.length(), n = t.length(), i, j, k;
  char dp[m + 1][n + 1][max(m, n) + 1];
  node dp1[m + 1][n + 1][max(m, n) + 1];
  for (i = 0; i <= m; i++)
    for (j = 0; j <= n; j++)
      for (k = 0; k <= max(m, n); k++) dp[i][j][k] = 'n';
  dp[0][0][0] = 's';
  queue<node> q;
  node nd0 = {0, 0, 0}, nd1;
  q.push(nd0);
  char ch1;
  while (!q.empty()) {
    nd0 = q.front();
    i = nd0.i, j = nd0.j, k = nd0.k;
    q.pop();
    nd1 = nd0;
    nd1.k++;
    if (i + 1 <= m && s[i + 1 - 1] == '(') nd1.i++;
    if (nd1.i <= m && nd1.j <= n && nd1.k >= 0 && nd1.k <= max(m, n) &&
        dp[nd1.i][nd1.j][nd1.k] == 'n') {
      dp[nd1.i][nd1.j][nd1.k] = '(';
      dp1[nd1.i][nd1.j][nd1.k] = nd0;
      q.push(nd1);
    }
    nd1 = nd0;
    nd1.k++;
    if (j + 1 <= n && t[j + 1 - 1] == '(') nd1.j++;
    if (nd1.i <= m && nd1.j <= n && nd1.k >= 0 && nd1.k <= max(m, n) &&
        dp[nd1.i][nd1.j][nd1.k] == 'n') {
      dp[nd1.i][nd1.j][nd1.k] = '(';
      dp1[nd1.i][nd1.j][nd1.k] = nd0;
      q.push(nd1);
    }
    nd1 = nd0;
    nd1.k++;
    if (i + 1 <= m && s[i + 1 - 1] == '(' && j + 1 <= n && t[j + 1 - 1] == '(')
      nd1.i++, nd1.j++;
    if (nd1.i <= m && nd1.j <= n && nd1.k >= 0 && nd1.k <= max(m, n) &&
        dp[nd1.i][nd1.j][nd1.k] == 'n') {
      dp[nd1.i][nd1.j][nd1.k] = '(';
      dp1[nd1.i][nd1.j][nd1.k] = nd0;
      q.push(nd1);
    }
    nd1 = nd0;
    nd1.k--;
    if (i + 1 <= m && s[i + 1 - 1] == ')') nd1.i++;
    if (nd1.i <= m && nd1.j <= n && nd1.k >= 0 && nd1.k <= max(m, n) &&
        dp[nd1.i][nd1.j][nd1.k] == 'n') {
      dp[nd1.i][nd1.j][nd1.k] = ')';
      dp1[nd1.i][nd1.j][nd1.k] = nd0;
      q.push(nd1);
    }
    nd1 = nd0;
    nd1.k--;
    if (j + 1 <= n && t[j + 1 - 1] == ')') nd1.j++;
    if (nd1.i <= m && nd1.j <= n && nd1.k >= 0 && nd1.k <= max(m, n) &&
        dp[nd1.i][nd1.j][nd1.k] == 'n') {
      dp[nd1.i][nd1.j][nd1.k] = ')';
      dp1[nd1.i][nd1.j][nd1.k] = nd0;
      q.push(nd1);
    }
    nd1 = nd0;
    nd1.k--;
    if (i + 1 <= m && s[i + 1 - 1] == ')' && j + 1 <= n && t[j + 1 - 1] == ')')
      nd1.i++, nd1.j++;
    if (nd1.i <= m && nd1.j <= n && nd1.k >= 0 && nd1.k <= max(m, n) &&
        dp[nd1.i][nd1.j][nd1.k] == 'n') {
      dp[nd1.i][nd1.j][nd1.k] = ')';
      dp1[nd1.i][nd1.j][nd1.k] = nd0;
      q.push(nd1);
    }
  }
  string res = "";
  char ch;
  i = m, j = n, k = 0;
  while (i > 0 || j > 0 || k > 0) {
    res += dp[i][j][k];
    int ti = dp1[i][j][k].i;
    int tj = dp1[i][j][k].j;
    int tk = dp1[i][j][k].k;
    i = ti, j = tj, k = tk;
  }
  reverse(res.begin(), res.end());
  cout << res;
}