Problem: Uncle Bogdan is in captain Flint's crew for a long time and sometimes gets nostalgic for his homeland. Today he told you how his country introduced a happiness index.

There are n cities and n−1 undirected roads connecting pairs of cities. Citizens of any city can reach any other city traveling by these roads. Cities are numbered from 1 to n and the city 1 is a capital. In other words, the country has a tree structure.

There are m citizens living in the country. A p_i people live in the i-th city but all of them are working in the capital. At evening all citizens return to their home cities using the shortest paths. 

Every person has its own mood: somebody leaves his workplace in good mood but somebody are already in bad mood. Moreover any person can ruin his mood on the way to the hometown. If person is in bad mood he won't improve it.

Happiness detectors are installed in each city to monitor the happiness of each person who visits the city. The detector in the i-th city calculates a happiness index h_i as the number of people in good mood minus the number of people in bad mood. Let's say for the simplicity that mood of a person doesn't change inside the city.

Happiness detector is still in development, so there is a probability of a mistake in judging a person's happiness. One late evening, when all citizens successfully returned home, the government asked uncle Bogdan (the best programmer of the country) to check the correctness of the collected happiness indexes.

Uncle Bogdan successfully solved the problem. Can you do the same?

More formally, You need to check: "Is it possible that, after all people return home, for each city i the happiness index will be equal exactly to h_i".

Input

The first line contains a single integer t (1 ≤ t ≤ 10000) — the number of test cases.

The first line of each test case contains two integers n and m (1 ≤ n ≤ 10^5; 0 ≤ m ≤ 10^9) — the number of cities and citizens.

The second line of each test case contains n integers p_1, p_2, …, p_{n} (0 ≤ p_i ≤ m; p_1 + p_2 + … + p_{n} = m), where p_i is the number of people living in the i-th city.

The third line contains n integers h_1, h_2, …, h_{n} (-10^9 ≤ h_i ≤ 10^9), where h_i is the calculated happiness index of the i-th city.

Next n − 1 lines contain description of the roads, one per line. Each line contains two integers x_i and y_i (1 ≤ x_i, y_i ≤ n; x_i ≠ y_i), where x_i and y_i are cities connected by the i-th road.

It's guaranteed that the sum of n from all test cases doesn't exceed 2 ⋅ 10^5.

Output

For each test case, print YES, if the collected data is correct, or NO — otherwise. You can print characters in YES or NO in any case.

Examples

Input


2
7 4
1 0 1 1 0 1 0
4 0 0 -1 0 -1 0
1 2
1 3
1 4
3 5
3 6
3 7
5 11
1 2 5 2 1
-11 -2 -6 -2 -1
1 2
1 3
1 4
3 5


Output


YES
YES


Input


2
4 4
1 1 1 1
4 1 -3 -1
1 2
1 3
1 4
3 13
3 3 7
13 1 4
1 2
1 3


Output


NO
NO

Note

Let's look at the first test case of the first sample: 

<image>

At first, all citizens are in the capital. Let's describe one of possible scenarios: 

  * a person from city 1: he lives in the capital and is in good mood; 
  * a person from city 4: he visited cities 1 and 4, his mood was ruined between cities 1 and 4; 
  * a person from city 3: he visited cities 1 and 3 in good mood; 
  * a person from city 6: he visited cities 1, 3 and 6, his mood was ruined between cities 1 and 3; 

In total, 
  * h_1 = 4 - 0 = 4, 
  * h_2 = 0, 
  * h_3 = 1 - 1 = 0, 
  * h_4 = 0 - 1 = -1, 
  * h_5 = 0, 
  * h_6 = 0 - 1 = -1, 
  * h_7 = 0. 



The second case of the first test: 

<image>

All people have already started in bad mood in the capital — this is the only possible scenario.

The first case of the second test: 

<image>

The second case of the second test: 

<image>

It can be proven that there is no way to achieve given happiness indexes in both cases of the second test. 

Solution (in JAVA):

Solution:
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main
{
    static class Graph{
        int N, M;
        long h[], t[], pGood[], pBad[], p[];
        ArrayList<Integer> l[];

        public Graph(int N, int M, long h[], long p[]){
            this.N = N;
            this.M = M;
            this.h = h.clone();
            this.p = p.clone();

            pBad = new long[N + 1];
            pGood = new long[N + 1];
            t = new long[N + 1];

            l = new ArrayList[N + 1];
            for(int i = 0; i <= N; i++)
                l[i] = new ArrayList<>();
        }

        void addEdge(int u, int v){
            l[u].add(v);
            l[v].add(u);
        }   

        /*
            Calculate the total no. of ppl who'll cross this node
        */
        void peopleCrossing(int node, int par){
            t[node] = p[node];
            for(int child : l[node]){
                if(child == par)
                    continue;
                peopleCrossing(child, node);
                t[node] += t[child];
            }
        }

        /*
            dfs() calculates the pGood[i] and pBad[i] for each node.
            If there is some inconsistency like (h[i] + t[i]) is'nt even or no. of 
            ppl is negative or greater than M, it returns false
        */
        boolean dfs(int node, int par){ 
            long sum = h[node] + t[node];
            if((sum & 1) == 1 || sum < 0)
                return false;
            long goodMood = sum / 2,
                badMood = t[node] - goodMood; 
            if(badMood < 0 || goodMood > M || badMood > M || goodMood > t[node] || badMood > t[node])
                return false;
            pGood[node] = goodMood;
            pBad[node] = badMood;

            boolean ret = true;
            for(int child : l[node]){
                if(child == par)
                    continue;
                boolean consistent = dfs(child, node);
                ret = ret && consistent;
            }

            return ret;
        }

        /*
            dataConsistent() tells if the pGood and pBad we've calculated is consistent with the provided 
            constraint or not i.e, 
            "Every person has its own mood: somebody leaves his workplace in good mood but somebody are 
            already in bad mood. 
            Moreover any person can ruin his mood on the way to the hometown. 
            If person is in bad mood he won't improve it."
        */

        boolean dataConsistent(){
            Queue<Integer> q = new LinkedList<>();
            boolean visited[] = new boolean[N + 1];
            visited[1] = true;
            q.add(1);

            while(!q.isEmpty()){
                int node = q.poll();
                long totalGood = 0l, totalBad = 0l;
                for(int child : l[node]){
                    if(visited[child])
                        continue;

                    totalGood += pGood[child];
                    totalBad += pBad[child];
                    visited[child] = true;
                    q.add(child);
                }

                if(totalGood > pGood[node]){
                    return false;
                }
            }

            return true;
        }
    }

    public static void process(int test_number)throws IOException
    {
        int N = ni(), M = ni();
        long h[] = new long[N + 1], p[] = new long[N + 1];
        for(int i = 1; i <= N; i++)
            p[i] = ni();
        for(int i = 1; i <= N; i++)
            h[i] = ni();

        Graph G = new Graph(N, M, h, p);
        for(int i = 1; i < N; i++){
            int u = ni(), v = ni();
            G.addEdge(u, v);
        }

        G.peopleCrossing(1, 0);
        boolean possible = G.dfs(1, 0);
        if(!possible){
            pn("NO");
        }else{
            possible = G.dataConsistent();
            pn(possible ? "YES" : "NO");
        }
    }
 
    static final long mod = (long)1e9+7l;
    static boolean DEBUG = true;
    static FastReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc = new FastReader();
 
        long s = System.currentTimeMillis();
        int t = 1;
        t = ni();
        for(int i = 1; i <= t; i++)
            process(i);
 
        out.flush();
        System.err.println(System.currentTimeMillis()-s+"ms");
    }

    static void trace(Object... o){ if(!DEBUG) return; System.err.println(Arrays.deepToString(o)); };    
    static void pn(Object o){ out.println(o); }
    static void p(Object o){ out.print(o); }
    static int ni()throws IOException{ return Integer.parseInt(sc.next()); }
    static long nl()throws IOException{ return Long.parseLong(sc.next()); }
    static double nd()throws IOException{ return Double.parseDouble(sc.next()); }
    static String nln()throws IOException{ return sc.nextLine(); }
    static long gcd(long a, long b){ return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b){ return (b==0)?a:gcd(b,a%b); }
    
    static class FastReader{ 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader(){ 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next(){ 
            while (st == null || !st.hasMoreElements()){ 
                try{ st = new StringTokenizer(br.readLine()); } catch (IOException  e){ e.printStackTrace(); } 
            } 
            return st.nextToken(); 
        } 
  
        String nextLine(){ 
            String str = ""; 
            try{ str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } 
            return str; 
        } 
    } 
}