Yulia wrote the number $x$ on the blackboard, and Zakhar wrote $y$. The kids are bored and have come up with an extremely captivating activity. Once every minute, they erase their numbers simultaneously and write new numbers instead. Yulia writes new numbers according to the following rule: if her number equaled $i$, it is substituted by $f_i$. Zakhar does the same, but the rule is different: if his number equaled $i$, it is substituted by $g_i$.
They will stop when their numbers match. This coould happen right away (if $x=y$), or later, or maybe never. Your task is to determine for different values of $x$ and $y$, if the kids will ever end writing out numbers.
The first line contains two integers: $N$ and $Q$ ($1\leq N,Q\leq 10^5$).
The second line contains $N$ numbers separated by spaces: $f_1,\ldots,f_N$.
The third line contains numbers in the same format: $g_1,\ldots,g_N$.
In the $j$th of the following $Q$ lines there are the initial numbers $x_j$ and $y_j$.
It is guaranteed that the numbers $f_i$, $g_i$, $x_j$, $y_j$ are all integers and fall within the range of $1$ through $N$.
Print $Q$ lines: in the $j$th line, print YES, if the process that started from the numbers $x_j$ and $y_j$, ends, and NO otherwise.