This page is still under construction.

Parts of this page are still being built. What you see may change.

La Vie En Rose

Time limit2.5sMemory limit64 MB

Summary
Count which length-m windows of s can be produced from pattern p by swapping disjoint adjacent pairs that are non-overlapping and strictly separated.
Level

Hard8 of 10

Topics
String matching, Dynamic programming, String, Bit manipulation
Solved
No attempts yet

Problem

Professor Zhang would like to solve the multiple pattern matching problem, but he has only one pattern string p=p1p2…pmp = p_{1} p_{2} \ldots p_{m}. So he wants to generate as many pattern strings as possible from pp using the following method:

  1. Select some indices i1,i2,…,iki_1, i_2, \ldots, i_k such that 1≤i1<i2<…<ik<∣p∣1 \le i_1 < i_2 < \ldots < i_k < |p| and ∣ij−ij+1∣>1|i_{j} - i_{j + 1}| > 1 for all 1≤j<k1 \le j < k.
  2. Swap pijp_{i_{j}} and pij+1p_{i_{j} + 1} for all 1≤j≤k1 \le j \le k.

Now, given a string s=s1s2…sns = s_{1} s_{2} \ldots s_{n}, Professor Zhang wants to find all occurrences of all the generated patterns in ss.

Input

The first line contains two integers nn and mm (1≤n≤1051 \le n \le 10^5, 1≤m≤min⁡(50 000,n)1 \le m \le \min (50\,000, n)): the lengths of ss and pp, respectively.

The second line contains the string ss, and the third line contains the string pp. Both strings consist only of lowercase English letters.

Output

Output a binary string of length nn. The ii-th character must be '1' if and only if the substring sisi+1…si+m−1s_{i} s_{i+1} \ldots s_{i+m-1} is one of the generated patterns. Otherwise, the character must be '0'.

Examples3

  1. Example 1

    Input
    4 1
    abac
    a
    
    Expected output
    1010
    
  2. Example 2

    Input
    4 2
    aaaa
    aa
    
    Expected output
    1110
    
  3. Example 3

    Input
    9 3
    abcbacacb
    abc
    
    Expected output
    100100100