func_code_string: #include <bits/stdc++.h>   using namespace std;   vector<int> v[100005];   int p[100005];   int h[100005];   int happy[100005];   int sad[100005];   bool vis[100005];   bool ok;   void init(int n) {     for (int i = 1; i < n + 1; i++) {       v[i].clear();       vis[i] = false;     }     ok = true;   }   void dfs(int node) {     vis[node] = true;     long long int happyChild = 0;     long long int sadChild = p[node];     for (int child : v[node]) {       if (vis[child]) continue;       dfs(child);       happyChild += happy[child];       sadChild += sad[child];     }     long long int gg = (long long int)h[node] - (happyChild - sadChild);     if (gg >= 0 && gg % 2 == 0 && gg / 2 <= sadChild) {       long long int x = gg / 2;       happy[node] = x + happyChild;       sad[node] = sadChild - x;     } else {       ok = false;       return;     }   }   int main() {     int t, n, m, a, b;     scanf( %d , &t);     while (t--) {       scanf( %d %d , &n, &m);       init(n);       for (int i = 1; i < n + 1; i++) scanf( %d , &p[i]);       for (int i = 1; i < n + 1; i++) scanf( %d , &h[i]);       for (int i = 0; i < n - 1; i++) {         scanf( %d %d , &a, &b);         v[a].push_back(b);         v[b].push_back(a);       }       dfs(1);       if (ok)         puts( YES );       else         puts( NO );     }     return 0;   }   