Problems
CHM
CHM
Your task - to implement \textbf{Persistent Disjoint-Set-Union}. What does this mean?
About \textbf{Disjoint-Set-Union}:
Initially, you have \textbf{n} elements. We must learn to respond to two types of queries.
\begin{itemize}
\item + a b --- combine a set that contains the vertices \textbf{a} and \textbf{b};
\item say, are whether the top \textbf{a} and \textbf{b} now in one set.
\end{itemize}
About \textbf{Persistent}:
Now we will have multiple copies (versions) of the data structure \textbf{Disjoint-Set-Union}.
Requests will look like this:
\begin{itemize}
\item \textbf{+ i a b} --- a request to the \textbf{i}-th structure, to combine a set that contains the vertices \textbf{a} and \textbf{b}. In this case, the \textbf{i}-th structure remains unchanged, a new version, it is assigned a new number (which? Read on);
\item \textbf{? i a b} --- a request to the i-th structure, say there are vertices \textbf{a} and \textbf{b} are in one set.
\end{itemize}
\InputFile
On the first line \textbf{2} of the \textbf{N} (\textbf{1} ≤ \textbf{N} ≤ \textbf{10^5}) и \textbf{K} (\textbf{0} ≤ \textbf{K} ≤ \textbf{10^5}) --- the number of items and the number of requests. Initially, all elements are in different sets. This is the original copy (version) of the structure is numbered \textbf{0}.
Followed by \textbf{K} lines for each description of the next request. The format of queries described above. Requests are numbered from \textbf{1} to \textbf{K}.
In processing the \textbf{j}-th query of the form \textbf{+ i a b}, the new version will get the number \textbf{j}.
Requests to non-existent version will not be (\textbf{j} > \textbf{i}).
\OutputFile
For each query type \textbf{? i a b} on a separate line to display \textbf{YES} or \textbf{NO}.
Input example #1
4 7 + 0 1 2 ? 0 1 2 ? 1 1 2 + 1 2 3 ? 4 3 1 ? 0 4 4 ? 4 1 4
Output example #1
NO YES YES YES NO