import
java.io.*;
import
java.util.*;
class
GFG {
static
int
[][] dp =
new
int
[
100
][
100
];
static
String smallestSubstring(String A, String B)
{
int
a = A.length();
int
b = B.length();
for
(
int
i =
0
; i < a; ++i) {
if
(i >
0
&& A.charAt(i) != B.charAt(
0
)) {
dp[i][
0
] = dp[i -
1
][
0
];
}
if
(A.charAt(i) == B.charAt(
0
)) {
dp[i][
0
] = i;
}
}
for
(
int
j =
1
; j < b; ++j) {
for
(
int
i =
1
; i < a; ++i) {
if
(A.charAt(i) == B.charAt(j)) {
dp[i][j] = dp[i -
1
][j -
1
];
}
else
{
dp[i][j] = dp[i -
1
][j];
}
}
}
String answer =
""
;
int
best_length =
100000000
;
for
(
int
i =
0
; i < a; ++i) {
if
(dp[i][b -
1
] != -
1
) {
int
start = dp[i][b -
1
];
int
end = i;
int
current_length = end - start +
1
;
if
(current_length < best_length) {
best_length = current_length;
answer = A.substring(start, best_length+
1
);
}
}
}
return
answer;
}
static
void
smallestSubstringUtil(String A, String B)
{
for
(
int
i=
0
;i<
100
;i++)
{
for
(
int
j=
0
;j<
100
;j++)
{
dp[i][j] = -
1
;
}
}
System.out.print( smallestSubstring(A, B) );
}
public
static
void
main(String[] args)
{
String A =
"abcedbaced"
;
String B =
"bed"
;
smallestSubstringUtil(A, B);
}
}