~/algor $ cat problems/ikki-korsatkich-eng-qisqa-qamrov
Minimum window substring
Medium
1000 ms
128 MB
66%
Two strings $s$ and $t$ are given. Find the shortest segment of consecutive letters of $s$ in which every letter of $t$ occurs at least as many times as in $t$ (for example, for $t$ = aab the segment must contain at least two a and one b). If there are several such segments, print the leftmost one; if there are none, print $-1$.
Input
The first line contains $s$, the second line contains $t$.
Output
The found substring, or $-1$.
Note
$1 \le |t| \le |s| \le 10^{5}$
the strings consist of lowercase Latin letters
Examples
Input #1
adobecodebanc abc
Output #1
banc
Input #2
aab abb
Output #2
-1