Is It a p-drome?

아직 제출이 없습니다시간 제한5초메모리 제한256 MB

문제

Let's suppose that we have fixed a permutation pp with length nn. We say that a string tt is a pp-drome if it has the length nn, and for all the characters of this string, it is true that t_i=t_p_it\_i = t\_{p\_i}.

You have a string ss and a permutation pp. For each substring of ss of length nn, you have to find out if it is a pp-drome or not.

입력

On the first line, you are given three integers nn, mm, and cc: the length of the permutation, the length of the string and the size of the alphabet of the string (1nm500,0001 \le n \le m \le 500\\,000; 1c500,0001 \le c \le 500\\,000).

On the second line, you are given nn integers p_ip\_i: the permutation itsekf (1p_in1 \le p\_i \le n; p_ip_jp\_i \ne p\_j if iji \ne j).

On the third line, you are given mm integers s_is\_i: the initial string (1s_ic1 \le s\_i \le c).

출력

Print mn+1m-n+1 characters without spaces: ii-th character must be "1" if substring s_is_i+n1s\_i \ldots s\_{i+n-1} is a pp-drome, and "0" otherwise.