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;
const int N = 200;
int dp[N + 10][N + 10][2 * N + 10];
pair<pair<int, int>, int> par[N + 10][N + 10][2 * N + 10];
const int inf = 1e6;
int main() {
  string s, t;
  cin >> s >> t;
  int szs = s.size(), szt = t.size();
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= N; j++) {
      for (int k = 0; k <= 2 * N; k++) {
        dp[i][j][k] = inf;
      }
    }
  }
  dp[0][0][0] = 0;
  for (int i = 0; i <= szs; i++) {
    for (int j = 0; j <= szt; j++) {
      if (i == szs && j == szt) {
        for (int k = 2 * N; k > 0; k--) {
          int c = dp[i][j][k - 1];
          dp[i][j][k - 1] = min(dp[i][j][k - 1], dp[i][j][k] + 1);
          if (dp[i][j][k - 1] < c) {
            par[i][j][k - 1] = make_pair(make_pair(i, j), k);
          }
        }
      } else if (i == szs) {
        if (t[j] == '(') {
          for (int k = 2 * N; k > 0; k--) {
            int c = dp[i][j][k - 1];
            dp[i][j][k - 1] = min(dp[i][j][k - 1], dp[i][j][k] + 1);
            if (dp[i][j][k - 1] < c) {
              par[i][j][k - 1] = make_pair(make_pair(i, j), k);
            }
          }
          for (int k = 0; k < 2 * N; k++) {
            int c = dp[i][j + 1][k + 1];
            dp[i][j + 1][k + 1] = min(dp[i][j + 1][k + 1], dp[i][j][k] + 1);
            if (dp[i][j + 1][k + 1] < c) {
              par[i][j + 1][k + 1] = make_pair(make_pair(i, j), k);
            }
          }
        } else {
          for (int k = 0; k < 2 * N; k++) {
            int c = dp[i][j][k + 1];
            dp[i][j][k + 1] = min(dp[i][j][k + 1], dp[i][j][k] + 1);
            if (c > dp[i][j][k + 1]) {
              par[i][j][k + 1] = make_pair(make_pair(i, j), k);
            }
          }
          for (int k = 2 * N; k > 0; k--) {
            int c = dp[i][j + 1][k - 1];
            dp[i][j + 1][k - 1] = min(dp[i][j + 1][k - 1], dp[i][j][k] + 1);
            if (c > dp[i][j + 1][k - 1]) {
              par[i][j + 1][k - 1] = make_pair(make_pair(i, j), k);
            }
          }
        }
      } else if (j == szt) {
        if (s[i] == '(') {
          for (int k = 2 * N; k > 0; k--) {
            int c = dp[i][j][k - 1];
            dp[i][j][k - 1] = min(dp[i][j][k - 1], dp[i][j][k] + 1);
            if (c > dp[i][j][k - 1]) {
              par[i][j][k - 1] = make_pair(make_pair(i, j), k);
            }
          }
          for (int k = 0; k < 2 * N; k++) {
            int c = dp[i + 1][j][k + 1];
            dp[i + 1][j][k + 1] = min(dp[i + 1][j][k + 1], dp[i][j][k] + 1);
            if (c > dp[i + 1][j][k + 1]) {
              par[i + 1][j][k + 1] = make_pair(make_pair(i, j), k);
            }
          }
        } else {
          for (int k = 0; k < 2 * N; k++) {
            int c = dp[i][j][k + 1];
            dp[i][j][k + 1] = min(dp[i][j][k + 1], dp[i][j][k] + 1);
            if (c > dp[i][j][k + 1]) {
              par[i][j][k + 1] = make_pair(make_pair(i, j), k);
            }
          }
          for (int k = 2 * N; k > 0; k--) {
            int c = dp[i + 1][j][k - 1];
            dp[i + 1][j][k - 1] = min(dp[i + 1][j][k - 1], dp[i][j][k] + 1);
            if (c > dp[i + 1][j][k - 1]) {
              par[i + 1][j][k - 1] = make_pair(make_pair(i, j), k);
            }
          }
        }
      } else {
        if (s[i] == '(' && t[j] == ')') {
          for (int k = 0; k < 2 * N; k++) {
            int c = dp[i + 1][j][k + 1];
            dp[i + 1][j][k + 1] = min(dp[i + 1][j][k + 1], dp[i][j][k] + 1);
            if (c > dp[i + 1][j][k + 1]) {
              par[i + 1][j][k + 1] = make_pair(make_pair(i, j), k);
            }
          }
          for (int k = 2 * N; k > 0; k--) {
            int c = dp[i][j + 1][k - 1];
            dp[i][j + 1][k - 1] = min(dp[i][j + 1][k - 1], dp[i][j][k] + 1);
            if (c > dp[i][j + 1][k - 1]) {
              par[i][j + 1][k - 1] = make_pair(make_pair(i, j), k);
            }
          }
        } else if (s[i] == '(' && t[j] == '(') {
          for (int k = 2 * N; k > 0; k--) {
            int c = dp[i][j][k - 1];
            dp[i][j][k - 1] = min(dp[i][j][k - 1], dp[i][j][k] + 1);
            if (c > dp[i][j][k - 1]) {
              par[i][j][k - 1] = make_pair(make_pair(i, j), k);
            }
          }
          for (int k = 0; k < 2 * N; k++) {
            int c = dp[i + 1][j + 1][k + 1];
            dp[i + 1][j + 1][k + 1] =
                min(dp[i + 1][j + 1][k + 1], dp[i][j][k] + 1);
            if (c > dp[i + 1][j + 1][k + 1]) {
              par[i + 1][j + 1][k + 1] = make_pair(make_pair(i, j), k);
            }
          }
        } else if (s[i] == ')' && t[j] == ')') {
          for (int k = 0; k < 2 * N; k++) {
            int c = dp[i][j][k + 1];
            dp[i][j][k + 1] = min(dp[i][j][k + 1], dp[i][j][k] + 1);
            if (c > dp[i][j][k + 1]) {
              par[i][j][k + 1] = make_pair(make_pair(i, j), k);
            }
          }
          for (int k = 2 * N; k > 0; k--) {
            int c = dp[i + 1][j + 1][k - 1];
            dp[i + 1][j + 1][k - 1] =
                min(dp[i + 1][j + 1][k - 1], dp[i][j][k] + 1);
            if (c > dp[i + 1][j + 1][k - 1]) {
              par[i + 1][j + 1][k - 1] = make_pair(make_pair(i, j), k);
            }
          }
        } else {
          for (int k = 0; k < 2 * N; k++) {
            int c = dp[i][j + 1][k + 1];
            dp[i][j + 1][k + 1] = min(dp[i][j + 1][k + 1], dp[i][j][k] + 1);
            if (c > dp[i][j + 1][k + 1]) {
              par[i][j + 1][k + 1] = make_pair(make_pair(i, j), k);
            }
          }
          for (int k = 2 * N; k > 0; k--) {
            int c = dp[i + 1][j][k - 1];
            dp[i + 1][j][k - 1] = min(dp[i + 1][j][k - 1], dp[i][j][k] + 1);
            if (c > dp[i + 1][j][k - 1]) {
              par[i + 1][j][k - 1] = make_pair(make_pair(i, j), k);
            }
          }
        }
      }
    }
  }
  vector<int> seq;
  seq.push_back(0);
  int bal = 0;
  while (szs > 0 || szt > 0 || bal > 0) {
    pair<pair<int, int>, int> A = par[szs][szt][bal];
    szs = A.first.first;
    szt = A.first.second;
    bal = A.second;
    seq.push_back(bal);
  }
  reverse(seq.begin(), seq.end());
  string ans = "";
  for (int sz = seq.size(), i = 1; i < sz; i++) {
    if (seq[i] > seq[i - 1]) {
      ans += "(";
    } else {
      ans += ")";
    }
  }
  cout << ans << "\n";
}