While exploring the ruins of the ancient Amazon kingdom, Dr. Kim discovered two genealogies of queens. Each genealogy records, as a tree, the parent-child relationships between one original queen and her female descendants, as shown below. For example, in Figure 1, $C$ is the original queen, and $F$ and $D$ are children of $C$. The children of a person are unordered.
Figure 1
It was found that, before the two genealogies were discovered, zero or more elementary damage operations, defined below, had occurred.
Elementary damage: A parent $P$ and a child $Q$ of $P$ are merged into one person. All children of both people, except $Q$, become children of the merged person.
For example, applying elementary damage that merges $A$ and $F$ in Figure 2 gives Figure 3. Applying another elementary damage operation merging $B$ and $D$ in Figure 3 (Figure 4) then gives Figure 5.
Figure 2
Figure 3
Figure 4
Figure 5
Applying elementary damage that merges $E$ and $G$ in Figure 5 (Figure 6) gives Figure 7.
Figure 6
Figure 7
Fortunately, no elementary damage involved a person without children (those with numeric names in the figures). All people without children still have their names recorded, and their names are distinct. However, none of the names of people with children (those with alphabetic names in the figures) remain. Thus, the discovered genealogies look like Figure 8.
Figure 8
Different sequences of elementary damage on the same original genealogy can produce different results. However, the two genealogies in Figure 9 cannot come from the same original.
Figure 9
Write a program that determines whether the two given genealogies could have been obtained from the same original through zero or more elementary damage operations. The sets of names of childless people in the two given genealogies $S$ and $T$ are identical. That is, the set formed from the names of childless people in $S$ equals the corresponding set in $T$.
The recommended source file name is family.c or family.cpp, but a different name may also be submitted to the server.
Input
The following information is given on standard input. The first line contains the number of people $N_1$ in the first genealogy, the number $N_2$ in the second, and the number of childless people $K$ in each. People are numbered from $1$ to $N_1$ in the first genealogy and from $1$ to $N_2$ in the second. In both genealogies, people $1$ through $K$ have no children. People with the same number from $1$ through $K$ have the same name.
The next line gives each person’s parent number in the first genealogy, in order of the person’s number; $0$ is given for a person with no parent. The following line gives each person’s parent number in the second genealogy in the same order; $0$ is again given if there is no parent.
Output
On standard output, print YES if the two genealogies can come from the same original, or NO if this is impossible, using uppercase English letters.
Subtasks
In all subtasks, $1 \le K < N_1,N_2$.
- 1: 17/100 points; $2 \le N_1,N_2 \le 300$. The first genealogy has undergone no elementary damage.
- 2: 27/100 points; $2 \le N_1,N_2 \le 300$.
- 3: 15/100 points; $2 \le N_1,N_2 \le 5\,000$.
- 4: 41/100 points; $2 \le N_1,N_2 \le 300\,000$.
Examples
Input 1
3 3 2 3 3 0 3 3 0
Output 1
YES
Input 2
5 5 3 4 4 5 5 0 4 5 5 0 4
Output 2
NO
Input 3
7 8 4 7 7 6 6 0 5 5 6 7 7 8 0 5 5 5
Output 3
NO