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 dp[205][205][205], p[205][205][205];
int main() {
  char sa[205], sb[205], ans[410];
  int a, b, i, j, k, x, y, z, len = 1000, c, f;
  scanf("%s %s", sa, sb);
  a = strlen(sa);
  b = strlen(sb);
  memset(dp, 0x7f, sizeof(dp));
  for (i = 0; i <= a; i++) {
    for (j = 0; j <= b; j++) {
      for (k = 0; k <= 201; k++) {
        if (i == 0 && j == 0) {
          dp[i][j][k] = k;
          p[i][j][k] = 0;
        } else if (i == 0) {
          if (sb[j - 1] == '(') {
            if (k == 0) {
              dp[i][j][k] = dp[i][j - 1][k] + 2;
              p[i][j][k] = 32;
            } else {
              dp[i][j][k] = dp[i][j - 1][k - 1] + 1;
              p[i][j][k] = 33;
            }
          } else {
            if (k == 201) {
              dp[i][j][k] = dp[i][j - 1][k] + 2;
              p[i][j][k] = 32;
            } else {
              dp[i][j][k] = dp[i][j - 1][k + 1] + 1;
              p[i][j][k] = 31;
            }
          }
        } else if (j == 0) {
          if (sa[i - 1] == '(') {
            if (k == 0) {
              dp[i][j][k] = dp[i - 1][j][k] + 2;
              p[i][j][k] = 12;
            } else {
              dp[i][j][k] = dp[i - 1][j][k - 1] + 1;
              p[i][j][k] = 13;
            }
          } else {
            if (k == 201) {
              dp[i][j][k] = dp[i - 1][j][k] + 2;
              p[i][j][k] = 12;
            } else {
              dp[i][j][k] = dp[i - 1][j][k + 1] + 1;
              p[i][j][k] = 11;
            }
          }
        } else {
          if (sa[i - 1] == sb[j - 1]) {
            if (sa[i - 1] == '(') {
              if (k == 0) {
                if (dp[i][j][k] > dp[i - 1][j - 1][k] + 2) {
                  dp[i][j][k] = dp[i - 1][j - 1][k] + 2;
                  p[i][j][k] = 22;
                }
              } else {
                if (dp[i][j][k] > dp[i - 1][j - 1][k - 1] + 1) {
                  dp[i][j][k] = dp[i - 1][j - 1][k - 1] + 1;
                  p[i][j][k] = 23;
                }
              }
            } else {
              if (k == 201) {
                if (dp[i][j][k] > dp[i - 1][j - 1][k] + 2) {
                  dp[i][j][k] = dp[i - 1][j - 1][k] + 2;
                  p[i][j][k] = 22;
                }
              } else {
                if (dp[i][j][k] > dp[i - 1][j - 1][k + 1] + 1) {
                  dp[i][j][k] = dp[i - 1][j - 1][k + 1] + 1;
                  p[i][j][k] = 21;
                }
              }
            }
          }
          if (sa[i - 1] == '(') {
            if (k == 0) {
              if (dp[i][j][k] > dp[i - 1][j][k] + 2) {
                dp[i][j][k] = dp[i - 1][j][k] + 2;
                p[i][j][k] = 12;
              }
            } else {
              if (dp[i][j][k] > dp[i - 1][j][k - 1] + 1) {
                dp[i][j][k] = dp[i - 1][j][k - 1] + 1;
                p[i][j][k] = 13;
              }
            }
          } else {
            if (k == 201) {
              if (dp[i][j][k] > dp[i - 1][j][k] + 2) {
                dp[i][j][k] = dp[i - 1][j][k] + 2;
                p[i][j][k] = 12;
              }
            } else {
              if (dp[i][j][k] > dp[i - 1][j][k + 1] + 1) {
                dp[i][j][k] = dp[i - 1][j][k + 1] + 1;
                p[i][j][k] = 11;
              }
            }
          }
          if (sb[j - 1] == '(') {
            if (k == 0) {
              if (dp[i][j][k] > dp[i][j - 1][k] + 2) {
                dp[i][j][k] = dp[i][j - 1][k] + 2;
                p[i][j][k] = 32;
              }
            } else {
              if (dp[i][j][k] > dp[i][j - 1][k - 1] + 1) {
                dp[i][j][k] = dp[i][j - 1][k - 1] + 1;
                p[i][j][k] = 33;
              }
            }
          } else {
            if (k == 201) {
              if (dp[i][j][k] > dp[i][j - 1][k] + 2) {
                dp[i][j][k] = dp[i][j - 1][k] + 2;
                p[i][j][k] = 32;
              }
            } else {
              if (dp[i][j][k] > dp[i][j - 1][k + 1] + 1) {
                dp[i][j][k] = dp[i][j - 1][k + 1] + 1;
                p[i][j][k] = 31;
              }
            }
          }
        }
        if (i == a && j == b) {
          if (len > dp[i][j][k] + k) {
            len = dp[i][j][k] + k;
            z = k;
          }
        }
      }
    }
  }
  x = a;
  y = b;
  c = 0;
  for (i = 0; i < z; i++) {
    ans[len - c - 1] = ')';
    c++;
  }
  while (c < len) {
    f = z;
    if (x == 0 && y == 0) {
      ans[len - c - 1] = '(';
      c++;
      continue;
    }
    if (p[x][y][z] % 10 == 1) {
      ans[len - c - 1] = ')';
      z += 1;
      c++;
    } else if (p[x][y][z] % 10 == 3) {
      ans[len - c - 1] = '(';
      z -= 1;
      c++;
    } else {
      ans[len - c - 1] = ')';
      c++;
      ans[len - c - 1] = '(';
      c++;
    }
    if (p[x][y][f] / 10 == 1) {
      x -= 1;
    } else if (p[x][y][f] / 10 == 3) {
      y -= 1;
    } else {
      x -= 1;
      y -= 1;
    }
  }
  for (i = 0; i < len; i++) printf("%c", ans[i]);
  printf("\n");
  return 0;
}