| Codeforces Round 1133 (Div. 2) |
|---|
| Finished |
You are given two integer arrays $$$a$$$ and $$$b$$$, each of length $$$n$$$. Furthermore, you are given an integer $$$k$$$.
You are allowed to perform any of the following operations zero or more times:
Determine if there is a way to apply these operations such that the resulting array $$$a$$$ is a permutation$$$^{\dagger}$$$ of $$$b$$$. Note that there are no restrictions on the values of the array during the process: elements may become negative or arbitrarily large.
$$$^{\dagger}$$$An array $$$a$$$ is a permutation of an array $$$b$$$ if $$$a$$$ consists of the elements of $$$b$$$ in arbitrary order. For example, $$$[4,2,3,4]$$$ is a permutation of $$$[3,2,4,4]$$$, while $$$[1,2,2]$$$ is not a permutation of $$$[1,2,3]$$$.
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 500$$$). The description of the test cases follows.
The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1\le n\le 100$$$, $$$0\le k\le 10^6$$$) — $$$n$$$ is the length of $$$a$$$ and $$$b$$$.
The second line of each testcase contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 10^6$$$).
The third line of each testcase contains $$$n$$$ integers $$$b_1, b_2, \ldots, b_n$$$ ($$$0 \le b_i \le 10^6$$$).
For each test case, print "YES" if it is possible to transform $$$a$$$ into a permutation of $$$b$$$, and "NO" otherwise.
You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.
53 41 2 75 3 81 1011 1106 10 0 0 0 0 01 3 7 15 31 632 1000000999999 11000000 1
YESYESNOYESYES
In the first test case, consider applying the following operations:
In the second test case, we can apply the operation $$$a[1] := 2\cdot a[1] + k$$$ to make $$$a = [1]$$$.
In the third test case, we can show that there is no way to make $$$a = [0]$$$.
| Name |
|---|


