Score : $500$ points
You are given integer sequences $A = (a_1,\ldots,a_N)$ and $B = (b_1,\ldots,b_N)$, each of length $N$.
For $i=1,...,Q$, answer the query in the following format.
Yes
; otherwise, print No
.Input is given from Standard Input in the following format:
$N$ $a_1$ $\ldots$ $a_N$ $b_1$ $\ldots$ $b_N$ $Q$ $x_1$ $y_1$ $\vdots$ $x_Q$ $y_Q$
Print $Q$ lines. The $i$-th line should contain the response to the $i$-th query.
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
Yes Yes Yes No No Yes No
Note that sets are a concept where it matters only whether each value is contained or not.
For the $3$-rd query, the first $2$ terms of $A$ contain one $1$ and one $2$, while the first $3$ terms of $B$ contain one $1$ and two $2$'s. However, the sets of values contained in the segments are both $\{ 1,2 \}$, which are equal.
Also, for the $6$-th query, the values appear in different orders, but they are still equal as sets.