Problem: Recently Lynyrd and Skynyrd went to a shop where Lynyrd bought a permutation of length , and Skynyrd bought an array of length , consisting of integers from to .
Lynyrd and Skynyrd became bored, so they asked you queries, each of which has the following form: "does the subsegment of from the -th to the -th positions, inclusive, have a subsequence that is a cyclic shift of ?" Please answer the queries.
A permutation of length is a sequence of integers such that each integer from to appears exactly once in it.
A cyclic shift of a permutation is a permutation for some from to . For example, a permutation has three distinct cyclic shifts: , , .
A subsequence of a subsegment of array from the -th to the -th positions, inclusive, is a sequence for some such that .
Input Format: The first line contains three integers , , () — the length of the permutation , the length of the array and the number of queries.
The next line contains integers from to , where the -th of them is the -th element of the permutation. Each integer from to appears exactly once.
The next line contains integers from to , the -th of them is the -th element of the array .
The next lines describe queries. The -th of these lines contains two integers and (), meaning that the -th query is about the subsegment of the array from the -th to the -th positions, inclusive.
Output Format: Print a single string of length , consisting of and , the digit on the -th positions should be , if the subsegment of array from the -th to the -th positions, inclusive, contains a subsequence that is a cyclic shift of , and otherwise.
Note: In the first example the segment from the -st to the -th positions is . There is a subsequence that is a cyclic shift of the permutation. The subsegment from the -nd to the -th positions also contains a subsequence that is equal to the permutation. The subsegment from the -rd to the -th positions is , there is only one subsequence of length (), but it is not a cyclic shift of the permutation.
In the second example the possible cyclic shifts are and . The subsegment from the -st to the -nd positions is , its subsequences are not cyclic shifts of the permutation. The subsegment from the -nd to the -rd positions is , it coincides with the permutation. The subsegment from the to the positions is , its subsequences are not cyclic shifts of the permutation.