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.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.TreeSet;
import java.util.function.Consumer;
import java.util.stream.Collectors;

public class C {

    public static void main(String[] args) throws IOException {
        new C().run();
    }
    
    int nt = 0;
    int ct = 0;
    int wnt = 4032;
    int wct = 0;
    boolean show;
    
    private void load_inputs(final BufferedReader br) throws IOException {
        try (
                PrintWriter pw = select_output();
        ) {
            int t = Integer.valueOf(br.readLine().trim());
            int ct = t;
            StringBuilder sb = new StringBuilder();
            while(t-- > 0) {
                nt++;
                show = wnt == nt && wct == ct;
                String line;
                line = br.readLine().trim();
                if(show) {
                    sb.append(line).append('\n');
                }
                int[] nm = Arrays.stream(line.split("\\s+")).mapToInt(v -> Integer.valueOf(v)).toArray();
                line = br.readLine().trim();
                if(show) {
                    sb.append(line).append('\n');
                }
                long[] p = Arrays.stream(line.split("\\s+")).mapToLong(v -> Long.valueOf(v)).toArray();
                line = br.readLine().trim();
                if(show) {
                    sb.append(line).append('\n');
                }
                long[] h = Arrays.stream(line.split("\\s+")).mapToLong(v -> Long.valueOf(v)).toArray();
                HashMap<Integer, ArrayList<Integer>> routes = new HashMap<>();
                for(int i = 0; i < nm[0] - 1; i++) {
                    line = br.readLine().trim();
                    if(show) {
                        sb.append(line).append('\n');
                    }
                    int[] xy = Arrays.stream(line.split("\\s+")).mapToInt(v -> Integer.valueOf(v) - 1).toArray();
                    if(!routes.containsKey(xy[0])) {
                        routes.put(xy[0], new ArrayList<>());
                    }
                    routes.get(xy[0]).add(xy[1]);
                    if(!routes.containsKey(xy[1])) {
                        routes.put(xy[1], new ArrayList<>());
                    }
                    routes.get(xy[1]).add(xy[0]);
                }
                if(show) {
                    System.out.println(sb);;
                }
                solve(nm[0], nm[1], p, h, routes, pw);
            }
        }
    }
    
    class NullOutputStream extends OutputStream {

        @Override
        public void write(int b) throws IOException {
        }
        
    }
    
    PrintStream debug = true ? System.out : new PrintStream(new NullOutputStream());

    private void solve(final int n, final int m, final long[] p, final long[] h, final HashMap<Integer, ArrayList<Integer>> routes, final PrintWriter pw) {
        boolean res = true;
        long[] p_in = new long[n];
        Arrays.fill(p_in, -1L);
        long[] p_in_happy = new long[n];
        long[] p_out_happy = new long[n];
        class Recursion {
            Consumer<Integer> proc = null;
        }
        Recursion recursion = new Recursion();
        recursion.proc = i -> {
            p_in[i] = p[i];
            if(routes.containsKey(i)) {
                routes.get(i).stream().filter(k -> p_in[k] == -1L).forEach(k -> {
                    recursion.proc.accept(k);
                    p_in[i] += p_in[k];
                    p_out_happy[i] += p_in_happy[k];
                });
            }
            if((p_in[i] + h[i]) % 2 != 0) {
                throw new RuntimeException();
            } else {
                p_in_happy[i] = (p_in[i] + h[i]) / 2;
                if(p_in_happy[i] < 0 || p_in_happy[i] > p_in[i] || p_in_happy[i] <  p_out_happy[i]) {
                    throw new RuntimeException();
                }
            }
        };
        try {
            recursion.proc.accept(0);
        } catch(Exception ex) {
            if(show) {
                System.out.println(ex);
            }
            res = false;
        }
        pw.println(res ? "YES" : "NO");
    }
    
    
    private void solve2(final int n, final int m, final long[] p, final long[] h, final HashMap<Integer, ArrayList<Integer>> routes, final PrintWriter pw) {
//        debug.println("---");
        boolean res = true;
        long[] p_in = new long[n];
        long[] p_in_happy = new long[n];
        long[] p_out_happy = new long[n];
        Consumer<Integer> calc_mood = i -> {
            if((p_in[i] + h[i]) % 2 != 0) {
                p_in_happy[i] = Long.MAX_VALUE;
            } else {
                p_in_happy[i] = (p_in[i] + h[i]) / 2;
                if(p_in_happy[i] < 0 || p_in_happy[i] > p_in[i] || p_in_happy[i] <  p_out_happy[i]) {
                    p_in_happy[i] = Long.MAX_VALUE;
                }
            }
        };
        if(routes.isEmpty()) {
            p_in[0] = p[0];
            p_out_happy[0] = 0;
            calc_mood.accept(0);
//            print_state.accept(0);
            if(p_in_happy[0] == Long.MAX_VALUE) {
                res = false;
            }
        } else {
//            debug.println("routes: " + routes);
//            debug.println("p: " + Arrays.stream(p).mapToObj(v -> Long.toString(v)).collect(Collectors.joining(" ")));
//            debug.println("h: " + Arrays.stream(h).mapToObj(v -> Long.toString(v)).collect(Collectors.joining(" ")));
            HashMap<Integer, ArrayList<Integer>> uptowns = new HashMap<Integer, ArrayList<Integer>>(){{
                put(-1, new ArrayList<Integer>(){{ 
                    add(0);
                }});
            }};
            HashMap<Integer, Integer> downtowns = new HashMap<>();
            ArrayList<Integer> queue = new ArrayList<>();
            queue.add(0);
            while(!queue.isEmpty()) {
                int node = queue.get(0);
                queue.remove((int)0);
                ArrayList<Integer> lst = uptowns.get(node);
                for(int k: routes.get(node)) {
                    if(!uptowns.containsKey(k)) {
                        if(lst == null) {
                            lst = new ArrayList<>();
                            uptowns.put(node, lst);
                        }
                        lst.add(k);
                        queue.add(k);
                    }
                }
            }
//            debug.println("uptowns: " + uptowns);
            ArrayList<Integer> ends = new ArrayList<>();
            while(res && !uptowns.isEmpty()) {
                ends.clear();
                uptowns.keySet().forEach(v -> {
                    List<Integer> ends1 = uptowns.get(v).stream().filter(k -> !uptowns.containsKey(k)).collect(Collectors.toList());
                    ends1.forEach(k -> downtowns.put(k, v));
                    ends.addAll(ends1);
                });
//                debug.println("ends: " + ends);
                res = ends.stream().allMatch(k -> {
                    p_in[k] = p[k];
                    p_out_happy[k] = 0;
                    routes.get(k).stream().filter(k1 -> !uptowns.containsKey(k1)).forEach(k1 -> {
                        p_in[k] += p_in[k1]; 
                        p_out_happy[k] += p_in_happy[k1];
                    });
                    calc_mood.accept(k);
                    if(p_in_happy[k] == Long.MAX_VALUE) {
                        return false;
                    }
                    uptowns.get(downtowns.get(k)).remove((Object)k);
                    if(uptowns.get(downtowns.get(k)).size() == 0) {
                        uptowns.remove(downtowns.get(k));
                    }
                    return true;
                });
//                debug.println("p_in: " + Arrays.stream(p_in).mapToObj(v -> Long.toString(v)).collect(Collectors.joining(" ")));
//                debug.println("p_in_happy: " + Arrays.stream(p_in_happy).mapToObj(v -> Long.toString(v)).collect(Collectors.joining(" ")));
//                debug.println("p_out_happy: " + Arrays.stream(p_out_happy).mapToObj(v -> Long.toString(v)).collect(Collectors.joining(" ")));
            }
        }
        pw.println(res ? "YES" : "NO");
    }
    
    private void solve1(final int n, final int m, final long[] p, final long[] h, final HashMap<Integer, ArrayList<Integer>> routes, final PrintWriter pw) {
//        System.out.println("---");
        boolean res = true;
        HashMap<Integer, ArrayList<Integer>> downtowns = new HashMap<>();
        long[] p_in = new long[n];
        Arrays.fill(p_in, Long.MAX_VALUE);
        long[] p_in_happy = new long[n];
        long[] p_out_happy = new long[n];
        Consumer<Integer> calc_mood = i -> {
            if((p_in[i] + h[i]) % 2 != 0) {
                p_in_happy[i] = Long.MAX_VALUE;
            } else {
                p_in_happy[i] = (p_in[i] + h[i]) / 2;
                if(p_in_happy[i] < 0 || p_in_happy[i] > p_in[i] || p_in_happy[i] <  p_out_happy[i]) {
                    p_in_happy[i] = Long.MAX_VALUE;
                }
            }
        };
        Consumer<Integer> print_state = k -> {
            System.out.println("k: " + k + ", p: " + p[k] + ", p_in: " + p_in[k] + ", p_in_happy: " + p_in_happy[k] + ", p_out_happy: " + p_out_happy[k]);

        };
        if(routes.isEmpty()) {
            p_in[0] = p[0];
            p_out_happy[0] = 0;
            calc_mood.accept(0);
//            print_state.accept(0);
            if(p_in_happy[0] == Long.MAX_VALUE) {
                res = false;
            }
        } else {
            HashMap<Integer, Integer> ends = new HashMap<>();
            TreeSet<Integer> downtowns1 = new TreeSet<>();
                    
            while(res && !routes.isEmpty()) {
                ends.clear();
                downtowns1.clear();
//                System.out.println("routes: " + routes);
//                System.out.println("p: " + Arrays.stream(p).mapToObj(v -> Integer.toString(v)).collect(Collectors.joining(" ")));
//                System.out.println("h: " + Arrays.stream(h).mapToObj(v -> Integer.toString(v)).collect(Collectors.joining(" ")));
                routes.keySet().stream().filter(k -> {
                    boolean ret = routes.get(k).size() == 1 && k != 0;
                    return ret;
                }).forEach(k -> ends.put(k, routes.get(k).get(0)));
//                if(ends.isEmpty()) {
//                    ends = routes.get(0).stream().collect(Collectors.toList());
//                }
//                System.out.println("ends: " + ends);
                downtowns1.addAll(ends.values());
                downtowns.clear();
                while(res && !downtowns1.isEmpty()) {
                    int downtown = downtowns1.pollFirst();
                    List<Integer> uptowns = routes.get(downtown).stream().filter(k -> ends.containsKey(k)).collect(Collectors.toList());
                    if(routes.get(downtown).size() - uptowns.size() == (downtown == 0 ? 0 : 1)) {
                        res = uptowns.stream().allMatch(k -> {
                            if(p_in[k] == Long.MAX_VALUE) {
                                p_in[k] = p[k];
                                p_out_happy[k] = 0;
                                calc_mood.accept(k);
        //                        print_state.accept(k);
                                if(p_in_happy[k] == Long.MAX_VALUE) {
                                    return false;
                                }
                            }
                            int k1 = routes.get(k).get(0);
                            if(!downtowns.containsKey(k1)) {
                                downtowns.put(k1, new ArrayList<>());
                            }
                            downtowns.get(k1).add(k);
                            routes.get(k1).remove((Object)k);
                            if(routes.get(k1).isEmpty()) {
                                routes.remove(k1);
                            }
                            routes.remove(k);
                            return true;
                        });
                    }
                }
//                downtowns.clear();
//                res = ends.stream().allMatch(k -> {
//                    if(p_in[k] == Long.MAX_VALUE) {
//                        p_in[k] = p[k];
//                        p_out_happy[k] = 0;
//                        calc_mood.accept(k);
////                        print_state.accept(k);
//                        if(p_in_happy[k] == Long.MAX_VALUE) {
//                            return false;
//                        }
//                    }
//                    int k1 = routes.get(k).get(0);
//                    if(!downtowns.containsKey(k1)) {
//                        downtowns.put(k1, new ArrayList<>());
//                    }
//                    downtowns.get(k1).add(k);
//                    routes.get(k1).remove((Object)k);
//                    if(routes.get(k1).isEmpty()) {
//                        routes.remove(k1);
//                    }
//                    routes.remove(k);
//                    return true;
//                });
                if(res) {
//                    System.out.println("downtowns: " + downtowns);
                    res = downtowns.keySet().stream().allMatch(k -> {
//                        System.out.println("downtown: " + k);
                        long[] p_out = new long[]{0};
                        p_out_happy[k] = 0;
                        downtowns.get(k).forEach(k1 -> {
                            p_out[0] += p_in[k1];
                            p_out_happy[k] += p_in_happy[k1];
                        });
                        p_in[k] = p[k] + p_out[0];
                        calc_mood.accept(k);
//                        print_state.accept(k);
                        if(p_in_happy[k] == Long.MAX_VALUE) {
                            return false;
                        }
                        return true;
                    });
                }
            }
        }
        pw.println(res ? "YES" : "NO");
    }

    String nameIn = getClass().getSimpleName() + ".in";
    String nameOut = null;

    private void run() throws IOException {
        File input = null;
        if (nameIn != null && (input = new File(nameIn)).exists()) {
            try (
                    FileReader fr = new FileReader(input);
                    BufferedReader br = new BufferedReader(fr);) {
                load_inputs(br);
            }
        } else {
            try (
                    InputStreamReader fr = new InputStreamReader(System.in);
                    BufferedReader br = new BufferedReader(fr);) {
                load_inputs(br);
            }
        }
    }

    PrintWriter select_output() throws FileNotFoundException {
        if (nameOut != null) {
            return new PrintWriter(nameOut);
        }
        return true ? new PrintWriter(System.out) : new PrintWriter(new Writer() {
            StringBuilder sb = new StringBuilder();
            @Override
            public void write(char[] cbuf, int off, int len) throws IOException {
                sb.append(cbuf, off, len);
            }

            @Override
            public void flush() throws IOException {
                throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
            }

            @Override
            public void close() throws IOException {
                System.out.print(sb);
            }
        });
    }
}