#d11207. 前缀集
前缀集
Prefix Sets
Problem Source
Problem Description
For a sequence , define its prefix set as the set of the first elements .
Given two sequences of length , and queries. Each query gives two positions . You need to determine whether the prefix set equals the prefix set .
Input Format
The first line contains an integer ().
The next two lines each contain integers, describing and respectively ().
The next line contains an integer ().
The following lines each contain two integers (), (), representing a query on and .
Output Format
Output lines. For each query, if the two prefix sets are equal, print Y; otherwise print N.
Sample Input
5
1 2 3 4 5
1 2 2 4 3
7
1 1
2 2
2 3
3 3
4 4
4 5
5 5
Sample Output
Y
Y
Y
N
N
Y
N