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;
int i, i0, n, m;
int dp[205][205][405];
int main() {
  string s, t;
  cin >> s >> t;
  for (int i = 0; i <= s.length(); i++) {
    for (int i0 = 0; i0 <= t.length(); i0++) {
      for (int p = 0; p <= 400; p++) {
        dp[i][i0][p] = 10000;
      }
    }
  }
  dp[0][0][0] = 0;
  for (int i = 0; i <= s.length(); i++) {
    for (int i0 = 0; i0 <= t.length(); i0++) {
      if (i == 0 && i0 == 0) continue;
      for (int p = 0; p <= 400; p++) {
        if (i && i0 && s[i - 1] == t[i0 - 1]) {
          if (s[i - 1] == '(') {
            if (p) {
              dp[i][i0][p] = min(dp[i][i0][p], dp[i - 1][i0 - 1][p - 1] + 1);
            }
          } else {
            dp[i][i0][p] = min(dp[i][i0][p], dp[i - 1][i0 - 1][p + 1] + 1);
            dp[i][i0][p] = min(dp[i][i0][p], dp[i - 1][i0 - 1][p] + 2);
          }
        }
        if (i && s[i - 1] == '(') {
          if (p) {
            dp[i][i0][p] = min(dp[i][i0][p], dp[i - 1][i0][p - 1] + 1);
          }
        } else if (i) {
          dp[i][i0][p] = min(dp[i][i0][p], dp[i - 1][i0][p + 1] + 1);
          dp[i][i0][p] = min(dp[i][i0][p], dp[i - 1][i0][p] + 2);
        }
        if (i0 && t[i0 - 1] == '(') {
          if (p) {
            dp[i][i0][p] = min(dp[i][i0][p], dp[i][i0 - 1][p - 1] + 1);
          }
        } else if (i0) {
          dp[i][i0][p] = min(dp[i][i0][p], dp[i][i0 - 1][p + 1] + 1);
          dp[i][i0][p] = min(dp[i][i0][p], dp[i][i0 - 1][p] + 2);
        }
      }
    }
  }
  int len = INT_MAX;
  for (int i = 0; i <= 400; i++) {
    len = min(len, i + dp[s.length()][t.length()][i]);
  }
  for (int x = 0; x <= 400; x++) {
    if (len == x + dp[s.length()][t.length()][x]) {
      string ans;
      int i = s.length(), i0 = t.length(), p = x;
      while (i != 0 || i0 != 0 || p != 0) {
        if (i && i0 && s[i - 1] == t[i0 - 1]) {
          if (s[i - 1] == '(') {
            if (p) {
              if (dp[i][i0][p] == dp[i - 1][i0 - 1][p - 1] + 1) {
                ans += s[i - 1];
                i--, i0--, p--;
                continue;
              }
            }
          } else {
            if (dp[i][i0][p] == dp[i - 1][i0 - 1][p + 1] + 1) {
              ans += s[i - 1];
              i--, i0--, p++;
              continue;
            }
            if (dp[i][i0][p] == dp[i - 1][i0 - 1][p] + 2) {
              i--, i0--;
              ans += ")(";
              continue;
            }
          }
        }
        if (i && s[i - 1] == '(') {
          if (p) {
            if (dp[i][i0][p] == dp[i - 1][i0][p - 1] + 1) {
              ans += s[i - 1];
              i--, p--;
              continue;
            }
          }
        } else if (i) {
          if (dp[i][i0][p] == dp[i - 1][i0][p + 1] + 1) {
            ans += s[i - 1];
            i--, p++;
            continue;
          }
          if (dp[i][i0][p] == dp[i - 1][i0][p] + 2) {
            i--;
            ans += ")(";
            continue;
          }
        }
        if (i0 && t[i0 - 1] == '(') {
          if (p) {
            if (dp[i][i0][p] == dp[i][i0 - 1][p - 1] + 1) {
              ans += t[i0 - 1];
              i0--, p--;
              continue;
            }
          }
        } else if (i0) {
          if (dp[i][i0][p] == dp[i][i0 - 1][p + 1] + 1) {
            ans += t[i0 - 1];
            i0--, p++;
            continue;
          }
          if (dp[i][i0][p] == dp[i][i0 - 1][p] + 2) {
            i0--;
            ans += ")(";
            continue;
          }
        }
      }
      reverse(ans.begin(), ans.end());
      while (x--) ans += ')';
      cout << ans << endl;
      break;
    }
  }
  return 0;
}