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 INF = 1 << 30;
int MOD = 1000000007;
int dp[210][210][210];
pair<pair<int, int>, int> par[210][210][210];
void solve() {
  string S, T;
  cin >> S >> T;
  for (int i = 0; i < (210); i++)
    for (int j = 0; j < (210); j++)
      for (int k = 0; k < (210); k++) dp[i][j][k] = INF;
  dp[0][0][0] = 0;
  for (int i = 0; i < (S.size() + 1); i++) {
    for (int j = 0; j < (T.size() + 1); j++) {
      for (int k = 0; k < (210); k++) {
        if (i == S.size() && j == T.size()) break;
        if (i == S.size()) {
          if (T[j] == '(') {
            if (dp[i][j + 1][k + 1] > dp[i][j][k] + 1) {
              dp[i][j + 1][k + 1] = dp[i][j][k] + 1;
              par[i][j + 1][k + 1] = {{i, j}, k};
            }
          } else {
            if (k == 0) {
              if (dp[i][j + 1][k] > dp[i][j][k] + 2) {
                dp[i][j + 1][k] = dp[i][j][k] + 2;
                par[i][j + 1][k] = {{i, j}, k};
              }
            } else {
              if (dp[i][j + 1][k - 1] > dp[i][j][k] + 1) {
                dp[i][j + 1][k - 1] = dp[i][j][k] + 1;
                par[i][j + 1][k - 1] = {{i, j}, k};
              }
            }
          }
        } else if (j == T.size()) {
          if (S[i] == '(') {
            if (dp[i + 1][j][k + 1] > dp[i][j][k] + 1) {
              dp[i + 1][j][k + 1] = dp[i][j][k] + 1;
              par[i + 1][j][k + 1] = {{i, j}, k};
            }
          } else {
            if (k == 0) {
              if (dp[i + 1][j][k] > dp[i][j][k] + 2) {
                dp[i + 1][j][k] = dp[i][j][k] + 2;
                par[i + 1][j][k] = {{i, j}, k};
              }
            } else {
              if (dp[i + 1][j][k - 1] > dp[i][j][k] + 1) {
                dp[i + 1][j][k - 1] = dp[i][j][k] + 1;
                par[i + 1][j][k - 1] = {{i, j}, k};
              }
            }
          }
        } else if (S[i] == T[j]) {
          if (S[i] == '(') {
            if (dp[i + 1][j + 1][k + 1] > dp[i][j][k] + 1) {
              dp[i + 1][j + 1][k + 1] = dp[i][j][k] + 1;
              par[i + 1][j + 1][k + 1] = {{i, j}, k};
            }
          } else {
            if (k == 0) {
              if (dp[i + 1][j + 1][k] > dp[i][j][k] + 2) {
                dp[i + 1][j + 1][k] = dp[i][j][k] + 2;
                par[i + 1][j + 1][k] = {{i, j}, k};
              }
            } else {
              if (dp[i + 1][j + 1][k - 1] > dp[i][j][k] + 1) {
                dp[i + 1][j + 1][k - 1] = dp[i][j][k] + 1;
                par[i + 1][j + 1][k - 1] = {{i, j}, k};
              }
            }
          }
        } else {
          if (S[i] == '(') {
            if (dp[i + 1][j][k + 1] > dp[i][j][k] + 1) {
              dp[i + 1][j][k + 1] = dp[i][j][k] + 1;
              par[i + 1][j][k + 1] = {{i, j}, k};
            }
            if (k != 0) {
              if (dp[i][j + 1][k - 1] > dp[i][j][k] + 1) {
                dp[i][j + 1][k - 1] = dp[i][j][k] + 1;
                par[i][j + 1][k - 1] = {{i, j}, k};
              }
            }
          } else {
            if (dp[i][j + 1][k + 1] > dp[i][j][k] + 1) {
              dp[i][j + 1][k + 1] = dp[i][j][k] + 1;
              par[i][j + 1][k + 1] = {{i, j}, k};
            }
            if (k != 0) {
              if (dp[i + 1][j][k - 1] > dp[i][j][k] + 1) {
                dp[i + 1][j][k - 1] = dp[i][j][k] + 1;
                par[i + 1][j][k - 1] = {{i, j}, k};
              }
            }
          }
        }
      }
    }
  }
  int second = S.size(), t = T.size(), d;
  int m = INF;
  for (int i = 0; i < (210); i++) {
    if (m > dp[second][t][i] + i) {
      m = dp[second][t][i] + i;
      d = i;
    }
  }
  string ans = "";
  for (int i = 0; i < (d); i++) ans += ')';
  int cnt = 0;
  while (second != 0 || t != 0) {
    cnt++;
    int a, b, c;
    a = par[second][t][d].first.first;
    b = par[second][t][d].first.second;
    c = par[second][t][d].second;
    if (a == S.size()) {
      if (T[b] == '(') {
        ans += '(';
      } else {
        if (c == 0) {
          ans += ')';
          ans += '(';
        } else {
          ans += ')';
        }
      }
    } else if (b == T.size()) {
      if (S[a] == '(') {
        ans += '(';
      } else {
        if (c == 0) {
          ans += ')';
          ans += '(';
        } else {
          ans += ')';
        }
      }
    } else if (S[a] == T[b]) {
      if (S[a] == '(') {
        ans += '(';
      } else {
        if (c == 0) {
          ans += ')';
          ans += '(';
        } else {
          ans += ')';
        }
      }
    } else {
      if (S[a] == '(') {
        if (a == second) {
          ans += ')';
        } else {
          ans += '(';
        }
      } else {
        if (a == second) {
          ans += '(';
        } else {
          ans += ')';
        }
      }
    }
    second = a;
    t = b;
    d = c;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}
int main() { solve(); }