Problem: You are given strings s and t. Find one longest string that is a subsequence of both s and t.

Constraints

* s and t are strings consisting of lowercase English letters.
* 1 \leq |s|, |t| \leq 3000

Input

Input is given from Standard Input in the following format:


s
t


Output

Print one longest string that is a subsequence of both s and t. If there are multiple such strings, any of them will be accepted.

Examples

Input

axyb
abyxb


Output

axb


Input

aa
xayaz


Output

aa


Input

a
z


Output




Input

abracadabra
avadakedavra


Output

aaadara

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int al,bl,i,j;
  string a,b;
  cin>>a>>b;
  al=a.length();
  bl=b.length();
  string kotae[2][bl+1];
  for(i=0;i<bl+1;i++){
    kotae[0][i]="";
  }
  for(i=0;i<al;i++){
    for(j=-1;j<bl;j++){
      if(j==-1){
        kotae[1][j+1]="";
      }else if(a[i]==b[j]){
        kotae[1][j+1]=kotae[0][j]+a[i];
      }else if(kotae[0][j+1].length()>kotae[1][j].length()){
        kotae[1][j+1]=kotae[0][j+1];
      }else{
        kotae[1][j+1]=kotae[1][j];
      }
    }
    for(j=0;j<bl+1;j++){
      kotae[0][j]=kotae[1][j];
    }
  }
  cout<<kotae[0][bl];  
}