#P1537F. Figure Fixing

    ID: 575 Type: RemoteJudge 2000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>constructive algorithmsdfs and similardsugraphsgreedymath*2200

Figure Fixing

No submission language available for this problem.

Description

You have a connected undirected graph made of nn nodes and mm edges. The ii-th node has a value viv_i and a target value tit_i.

In an operation, you can choose an edge (i,j)(i, j) and add kk to both viv_i and vjv_j, where kk can be any integer. In particular, kk can be negative.

Your task to determine if it is possible that by doing some finite number of operations (possibly zero), you can achieve for every node ii, vi=tiv_i = t_i.

The first line contains a single integer tt (1t10001 \leq t \leq 1000), the number of test cases. Then the test cases follow.

The first line of each test case contains two integers nn, mm (2n21052 \leq n \leq 2\cdot 10^5, n1mmin(2105,n(n1)2)n-1\leq m\leq \min(2\cdot 10^5, \frac{n(n-1)}{2})) — the number of nodes and edges respectively.

The second line contains nn integers v1,vnv_1\ldots, v_n (109vi109-10^9 \leq v_i \leq 10^9) — initial values of nodes.

The third line contains nn integers t1,tnt_1\ldots, t_n (109ti109-10^9 \leq t_i \leq 10^9) — target values of nodes.

Each of the next mm lines contains two integers ii and jj representing an edge between node ii and node jj (1i,jn1 \leq i, j \leq n, iji\ne j).

It is guaranteed that the graph is connected and there is at most one edge between the same pair of nodes.

It is guaranteed that the sum of nn over all testcases does not exceed 21052 \cdot 10^5 and the sum of mm over all testcases does not exceed 21052 \cdot 10^5.

For each test case, if it is possible for every node to reach its target after some number of operations, print "YES". Otherwise, print "NO".

Input

The first line contains a single integer tt (1t10001 \leq t \leq 1000), the number of test cases. Then the test cases follow.

The first line of each test case contains two integers nn, mm (2n21052 \leq n \leq 2\cdot 10^5, n1mmin(2105,n(n1)2)n-1\leq m\leq \min(2\cdot 10^5, \frac{n(n-1)}{2})) — the number of nodes and edges respectively.

The second line contains nn integers v1,vnv_1\ldots, v_n (109vi109-10^9 \leq v_i \leq 10^9) — initial values of nodes.

The third line contains nn integers t1,tnt_1\ldots, t_n (109ti109-10^9 \leq t_i \leq 10^9) — target values of nodes.

Each of the next mm lines contains two integers ii and jj representing an edge between node ii and node jj (1i,jn1 \leq i, j \leq n, iji\ne j).

It is guaranteed that the graph is connected and there is at most one edge between the same pair of nodes.

It is guaranteed that the sum of nn over all testcases does not exceed 21052 \cdot 10^5 and the sum of mm over all testcases does not exceed 21052 \cdot 10^5.

Output

For each test case, if it is possible for every node to reach its target after some number of operations, print "YES". Otherwise, print "NO".

Samples

Sample Input 1

2
4 4
5 1 2 -3
3 3 10 1
1 2
1 4
3 2
3 4
4 4
5 8 6 6
-3 1 15 4
1 2
1 4
3 2
3 4

Sample Output 1

YES
NO

Note

Here is a visualization of the first test case (the orange values denote the initial values and the blue ones the desired values):

One possible order of operations to obtain the desired values for each node is the following:

  • Operation 11: Add 22 to nodes 22 and 33.
  • Operation 22: Add 2-2 to nodes 11 and 44.
  • Operation 33: Add 66 to nodes 33 and 44.

Now we can see that in total we added 2-2 to node 11, 22 to node 22, 88 to node 33 and 44 to node 44 which brings each node exactly to it's desired value.

For the graph from the second test case it's impossible to get the target values.