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.io.*;

import java.lang.annotation.Native;
import java.math.BigInteger;
import java.util.*;

import java.util.ArrayList;

import java.util.Scanner;


public class graph {
    static class pair {
        int first;
        int second;

        pair(int a, int b) {
            first = a;
            second = 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();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    static final int mod = 1000000007;
////////////////////////////////////gcd//////////////////////////////////////////////////////////////////

    public static int gcd(int a, int b) {
        if (a == 0)
            return b;
        return gcd(b % a, a);
    }
/////////////////////////////////////////////////////////////////////////////////////////////////////////


///////////////////////////////////////merge sort////////////////////////////////////////////////////////
    static boolean prime[] = new boolean[1000001];
    public static void merge(long arr[][], int l, int m, int r)
    {
        // Find sizes of two subarrays to be merged
        int n1 = m - l + 1;
        int n2 = r - m;

        /* Create temp arrays */
        long L[][] = new long[n1][2];
        long R[][] = new long[n2][2];

        /*Copy data to temp arrays*/
        for (int i = 0; i < n1; ++i)
        {
            L[i][0] = arr[l + i][0];
            L[i][1] = arr[l + i][1];


        }

        for (int j = 0; j < n2; ++j) {
            R[j][0] = arr[m + 1 + j][0];
            R[j][1] = arr[m + 1 + j][1];
        }

        /* Merge the temp arrays */

        // Initial indexes of first and second subarrays
        int i = 0, j = 0;

        // Initial index of merged subarry array
        int k = l;
        while (i < n1 && j < n2) {
            if (L[i][0] <= R[j][0]) {
                arr[k][0] = L[i][0];
                arr[k][1] = L[i][1];

                i++;
            }
            else {
                arr[k][0] = R[j][0];
                arr[k][1] = R[j][1];
                j++;
            }
            k++;
        }

        /* Copy remaining elements of L[] if any */
        while (i < n1) {
            arr[k][0] = L[i][0];
            arr[k][1] = L[i][1];
            i++;
            k++;
        }

        /* Copy remaining elements of R[] if any */
        while (j < n2) {
            arr[k][0] = R[j][0];
            arr[k][1] = R[j][1];

            j++;
            k++;
        }
    }

    public static long[][] sort2elementarray(long arr[][], int l, int r)
    {
        if (l < r) {
            // Find the middle point
            int m = (l + r) / 2;

            // Sort first and second halves
            sort2elementarray(arr, l, m);
            sort2elementarray(arr, m + 1, r);

            // Merge the sorted halves
            merge(arr, l, m, r);
        }
        return arr;
    }

/////////////////////////////////////////////////////////////////////////////////////////////////////////


///////////////////////////////////////DFS///////////////////////////////////////////////////////////////

    static int a[];
    static int b[];
    static int f=0;
    public static int dfs(ArrayList<Integer>[]li,int v,HashMap<Integer,Integer>hm,int p[],int h[]) {
        hm.put(v, 1);

        a[v] += p[v];

        //System.out.println(a[v]+" "+v);
        int sum = 0;
        for (int j = 0; j < li[v].size(); j++) {
            if (hm.get(li[v].get(j)) == null) {

                int s = dfs(li, li[v].get(j), hm, p, h);
                a[v] += s;
                b[v] += s;
                //System.out.println(sum);

            }

        }
        return a[v];


    }


    public static int dfs2(ArrayList<Integer>[]li,int v,int p[],int h[],HashMap<Integer,Integer>hm1) {
        /*for(int j=1;j<=n;j++) {
            System.out.println(a[j] + " " + b[j] + " " + h[j]);
        }*/

        if((a[v]+h[v])%2!=0)
            f=1;
        int x=(a[v]+h[v])/2;
        int c=0;
        hm1.put(v,1);
        //System.out.println(v+" "+x);

        for(int j=0;j<li[v].size();j++)
        {
            if(hm1.get(li[v].get(j))==null)
            {
                c+=dfs2(li,li[v].get(j),p,h,hm1);
            }

        }
        if(x<0||a[v]-x<0)
            f=1;
        if(c>x)
            f=1;


        return x;
    }


    public static void dfsutil(ArrayList<Integer>[]li,int n,int p[],int h[])
    {
        HashMap<Integer,Integer>hm=new HashMap<>();

        for(int j=1;j<=n;j++)
        {

            if(hm.get(j)==null)
            {
                //System.out.println("kk");
                dfs(li,j,hm,p,b);
            }
        }



    }
//////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////bipartite check////////////////////////////////////////////////////////////////////
public static void bipartite(ArrayList<Integer>[]li,int n)
    {
        int f=1;
        int col[]=new int[n+1];
        int fl=1;
        Arrays.fill(col,-1);
        for(int i=1;i<=n;i++)
        {
            if(col[i]==-1)
            {
                col[i]=1;
                Queue<Integer>q=new LinkedList<>();
                q.add(i);
                while (!q.isEmpty())
                {
                    int x=q.peek();
                    q.remove();
                    for(int j=0;j<li[x].size();j++)
                    {
                        if(col[li[x].get(j)]==-1)
                        {
                            col[li[x].get(j)]=1-col[x];
                            q.add(li[x].get(j));
                        }
                        else if(col[li[x].get(j)]==col[x])
                        {
                            f=0;
                            break;
                        }

                    }

                }
                if(f==0)
                {
                    fl=0;
                    break;
                }


            }

        }
        if(fl==0)
            System.out.println(-1);
        else
        {
            StringBuilder sb=new StringBuilder();
            StringBuilder sb1=new StringBuilder();
            int l1=0;
            int l2=0;
            for(int j=1;j<=n;j++)
            {
                if(col[j]==1)
                {l1++;
                    sb.append(j+" ");
                }else
                {l2++;sb1.append(j+" ");}
            }
            System.out.println(l1);
            System.out.println(sb);
            System.out.println(l2);
            System.out.println(sb1);
        }

    }
/////////////////////////////////////////////////////////////////////////////////////////////////////////




/////////////////////////topological sort////////////////////////////////////////////////////////////////
    static Stack<Integer>st=new Stack<>();
    public static void topological(ArrayList<Integer>[]li,int n,ArrayList<pair>edges)
    {
        HashMap<Integer,Integer>hm=new HashMap<>();
        for(int j=1;j<=n;j++)
        {

            if (hm.get(j) == null)
            {
                //dfs(li, j, hm);
            }
        }
        int pos[]=new int[n+1];
        for(int j=1;j<=n;j++)
        {
            pos[st.peek()]=j;
            st.pop();
        }
        boolean flag=false;
        for(int j=1;j<=n;j++)
        {
            for(int i=0;i<li[j].size();i++)
            {
                if(pos[j]>pos[li[j].get(i)])
                    flag=true;
            }
        }
        if(flag==true)
            System.out.println("NO");//cyclic
        else
        {
            System.out.println("YES");//acyclic
            for(int j=0;j<edges.size();j++)
            {
                if(pos[(edges.get(j)).first]<pos[(edges.get(j)).second])
                    System.out.println((edges.get(j)).first+" "+(edges.get(j)).second);
                else
                    System.out.println((edges.get(j)).second+" "+(edges.get(j)).first);

            }
        }

    }
/////////////////////////////////////////////////////////////////////////////////////////////////////////



    public static void main(String[] args) {
        FastReader sc = new FastReader();
        int t=sc.nextInt();
        for(int i=0;i<t;i++)
        {
            f=0;
            int n=sc.nextInt();
            int m=sc.nextInt();
            int p[]=new int[n+1];
            int h[]=new int[n+1];
            for(int j=1;j<=n;j++)
                p[j]=sc.nextInt();
            for(int j=1;j<=n;j++)
                h[j]=sc.nextInt();
            a=new int[n+1];
            b=new int[n+1];
            ArrayList<Integer>[]li=new ArrayList[n+1];
            for(int j=1;j<=n;j++)
            {
                li[j]=new ArrayList<>();

            }
            for(int j=0;j<n-1;j++)
            {

                int u=sc.nextInt();
                int v=sc.nextInt();
                li[u].add(v);
                li[v].add(u);

            }

           dfsutil(li,n,p,h);
            HashMap<Integer,Integer>hm1=new HashMap<>();
            dfs2(li,1,p,h,hm1);
            if(f==1)
                System.out.println("NO");
            else
                System.out.println("YES");


        }
    }
}