P14480 If I could be a comet...

Background

[彗星になれたなら](https://music.163.com/#/song?id=1474337895&uct2=U2FsdGVkX1/UcLNhgOn8Vac7ETvSzFJrXAgnlqX4mkQ=). > 空想ばかり話す僕だから > > 離れ離れになったのか

Description

To recreate the comet of that day, Nana and Lily need to use specific number pairs to transform one sequence into another. Nana has a sequence $a$ of length $n$. Lily can choose an index $i(1\le i

Input Format

Each data point starts with three integers $m, k, T$. The first $m$ lines, the $i$-th line has two integers $x_i, y_i$ indicating the $i$-th edge connects $(x_i,y_i)$. Then, there are $T$ test cases. Each test case input has three lines: - The first line is an integer $n$. - The second line is a sequence $a$ of length $n$, where the $i$-th number is $a_i$. - The third line is a sequence $b$ of length $n$, where the $i$-th number is $b_i$.

Output Format

For each test case, output one line with a string. If it is possible to transform $a$ into $b$, output `YES`; otherwise, output `NO`.

Explanation/Hint

### Sample Explanation For the first sample, we can operate as follows: 1. Choose $i=2$, the sequence becomes $[1,2,1,1,2,2]$. 2. Choose $i=1$, the sequence becomes $[2,1,1,1,2,2]$. 3. Choose $i=4$, the sequence becomes $[2,1,1,2,1,2]$. 4. Choose $i=5$, the sequence becomes $[2,1,1,2,2,1]$. For the second sample, clearly you cannot perform the first operation. So it is impossible. ### Data Range | Subtask | Data Range | Special Constraints | Score | | :-----: | :--------: | :-----------------: | :---: | | $1$ | $n\le 2$ | The graph is connected | $25$ | | $2$ | $n\le 10^5$ | The graph is connected | $25$ | | $3$ | $n\le 10^5$ | The graph is a forest | $25$ | | $4$ | $n\le 10^5$ | None | $25$ | This problem uses subtask bundling. You must pass all test points in a subtask to get the corresponding score. For all data, $1\le T\le 10^4$, $2\le n\le 10^5$, $\sum n\le 10^6$, $1\le m\le 3\times 10^5$, $1\le k\le 2\times 10^5$. It is guaranteed that $1\le a_i,b_i,x_i,y_i\le k$. The graph is **not** guaranteed to be without multiple edges or self-loops.